Dynamics AX Blog - Dynamics AX 2012 - Page 9

These posts are machine-translated.
Currently, only posts are displayed, which are relevant for Dynamics AX version »Dynamics AX 2012« Filter entfernen

RSS-Feed of this version

Get design names of a SSRS report

Anyone who has the need to get the available designs of a SSRS report, can use the following job.

static void listDesignsOfSSRSReport(Args _args)
{
    TreeNode treeNode;
    TreeNode treeNodeDesign;
    #aot
  
    treeNode = TreeNode::findNode(#SSRSReportsPath + #AOTRootPath);
    treeNode = treeNode.AOTfindChild("SalesPackingSlip");
    treeNodeDesign = treeNode.AOTfindChild("Designs");
  
    treeNodeDesign =
    treeNodeDesign.AOTfirstChild();
    while(treeNodeDesign)
    {
        info(treeNodeDesign.AOTname());   
      
        treeNodeDesign = treeNodeDesign.AOTnextSibling();
    }
}

 
 

Search project names for a specific string

To list all (shared-) pojects that carry a specific text in the name, you can use the following code.

static void searchProjectName(Args _args)
{
    ProjectNode projectNode;

    #AOTExport

    projectNode    = infolog.projectRootNode();
    projectNode    = projectNode.AOTfindChild(#expProjectShared);
    projectNode    = projectNode.AOTfirstChild();

    while(projectNode)
    {
        setPrefix(projectNode.name());

        if(strScan(projectNode.name(), "BR_", 0, 60))
        {
            info(projectNode.name());
        }

        projectNode    = projectNode.AOTnextSibling();
    }
}

 
 

Update explosion for production order

With the help of the following job you can update the explosion of a production order. This must at least have the status "Estimated".

static void reqCalcExplode(Args _args)
{
    ReqCalcExplodeProd reqCalcExplodeProd;
    ProdTable prodTable = ProdTable::find('P000272');
    ;
    // Copied from ReqCalcExplodeProd::newProdTablePrompt()
    reqCalcExplodeProd  = ReqCalcExplode::construct(ReqRefType::Production);

    reqCalcExplodeProd.parmRefType(ReqRefType::Production);
    reqCalcExplodeProd.parmRefId(prodTable.ProdId);
    reqCalcExplodeProd.parmInventTransOriginId(
        InventTransOriginProdTable::findInventTransOriginId(prodTable.DataAreaId, prodTable.ProdId));
    reqCalcExplodeProd.parmReqPlanId(ReqPlanSched::defaultDynamicId());
    reqCalcExplodeProd.parmReqCalcUpdate(ReqCalcUpdate::NetChangeMinimized);
    reqCalcExplodeProd.parmMarking(true);

    reqCalcExplodeProd.parmReqPlanData(null);

    reqCalcExplodeProd.run();
}

 

Screenshot


 
 

Restore DIXF/DMF entities

I recently had the problem, that all DIXF entities have been deleted in an environment. By following job I was able to restore them.

// Based on ClassesDMFDataPopulationcreateDefaultMapping
static void RecreateDMFEntities(Args _args)
{
    boolean             isFound;
    DMFEntity           dmfEntity;
    TmpDMFEntityList    entityDescription;
    Counter             c;

    entityDescription = DMFDataPopulation::getEntityList();

    ttsbegin;
    while select entityDescription
    {
        dmfEntity.EntityName         = entityDescription.EntityLabel;
        dmfEntity.EntityTypeName     = entityDescription.EntityName;
        dmfEntity.Mdm        = NoYes::No;
        isFound = dmfEntity.defaultModule(dmfEntity.EntityTypeName);

        if (isFound)
        {
            if (dmfEntity.validateWrite() &&
                ! DMFEntity::find(dmfEntity.EntityName))
            {
                dmfEntity.insert();
                c++;
            }
        }
    }
    ttscommit;
    
    info(strFmt("%1 entities created.", c));
}

 
 

Show only active employees in an employee-lookup

I recently had the requirement to integrate a new field for an employee in a table. So i created a table relation to Table HcmWorker, and added the field to the form.

Thus, a Reference Group was created and Dynamics AX generated the following lookup.

Screenshot


 
 

Create a list of favorites from current user

static void listFavoritesOfCurrentUser(Args _args)
{
    TreeNode treeNode;
    TreeNodeIterator iterator;
    TreeNode newTreeNode;
    int level;
    #AOT
    void loopChilds(TreeNode _treeNode)
    {
        level++;
        while(_treeNode)
        {
            info(strRep("    ", level-1) + any2str(SysLabel::labelId2String2(_treeNode.AOTname(), Global::currentUserLanguage())));
            loopChilds(_treeNode.AOTfirstChild());
            level--;
            _treeNode = _treeNode.AOTnextSibling();
        }
    }

    treeNode = infolog.userNode();
    iterator = treeNode.AOTiterator();
    treeNode = iterator.next();
    if (treeNode)
    {
        treeNode = treeNode.AOTfirstChild();
        if (treeNode)
        {
            setPrefix(treeNode.AOTname());
            loopChilds(treeNode.AOTfirstChild());
        }
    }
}

 
 

Read/modify registry

Following job demonstrates, how you can read/modify registry entries.

static void readWriteRegistry(Args _args)
{
    int                         regKey;
    container                   cRegValue;
    str                         regKeyValue;
    #WinApi

    // Read
    regKey = WinAPI::regOpenKey(#HKEY_CURRENT_USER, @"SoftwareMicrosoftDynamics6.0", #KEY_QUERY_VALUE);

    cRegValue = WinAPI::regGetValue(regKey, @"BuildVersion");
    if(conLen(cRegValue) > 0)
    {
        regKeyValue = conPeek(cRegValue, 1);
        info(strFmt("%1", regKeyValue));
    }

    WinAPI::regCloseKey(regKey);

    // Write
    regKey = WinAPI::regOpenKey(#HKEY_CURRENT_USER, @"SoftwareMicrosoftDynamics6.0", #KEY_QUERY_VALUE);
    cRegValue = WinAPI::regGetValue(regKey, @"BuildVersion");
    if(conLen(cRegValue) > 0)
    {
        regKey = WinAPI::regOpenKey(#HKEY_CURRENT_USER, @"SoftwareMicrosoftDynamics6.0", #KEY_WRITE);
        WinAPI::regSetValueEx(regKey, @"BuildVersion", 1, "Build: 6.3.164.0");
    }
    WinAPI::regCloseKey(regKey);
}

 
 
Pages « 1 ... 6 7 8 9 10 11 12 ... 22 » 

 

 
 
 
Posts of the actual month
November 2024
MoTuWeThFrSaSu
 123
45678910
11121314151617
18192021222324
252627282930 
 
© 2006-2024 Heinz Schweda | Imprint | Contact | German version | Desktop version
In order to provide you with better service, this site uses cookies. By continuing to browse the site, you are agreeing to our use of cookies.