Dynamics AX Blog - aot

These posts are machine-translated.
Currently, only posts are displayed, which contain the tag »aot« Filter entfernen

Create shared project by code, add objects and create groups for each object type

With the help of the job shown here, you can create a shared project by code, add objects and group them into groups per object type.

static void AddNodeToSharedProject(Args _args)
{
    projectNode projectNode;
    TreeNode treeNode;
    ProjectName projectName = "MyProject";
    
    #AOT
    #AOTExport
    
    void addTreeNodeToProjectNode(treeNode _treeNode)
    {
        TmpIdRef tmpIdRef;
            
        tmpIdRef.clear();
        tmpIdRef.Name = SysTreeNode::getPath(_treeNode);
        tmpIdRef.Mode = SysTreeNode::path2ApplObjectType(tmpIdRef.Name);
        tmpIdRef.useMode = UtilFileType::Application;
        tmpIdRef.insert();
        
        SysProjectFilterRunBase::addProjectNodes(tmpIdRef, projectNode);           
    }

    projectNode    = infolog.projectRootNode();
    projectNode    = projectNode.AOTfindChild(#expProjectShared);
    projectNode    = projectNode.AOTfindChild(projectName);
   
    // Create shared project if neccessary
    if( !projectNode)
    {
        projectNode = SysTreeNode::createProject(projectName, ProjectSharedPrivate::ProjShared);        
    }
    
    // Add objects (and create groups)
    treenode = TreeNode::findNode(#TablesPath+#AOTRootPath+tableid2name(tablenum(AccountingDistribution)));
    addTreeNodeToProjectNode(treenode);

    treenode = TreeNode::findNode(#TablesPath+#AOTRootPath+tableid2name(tablenum(VendGroup)));
    addTreeNodeToProjectNode(treenode);
   
    treenode = TreeNode::findNode(#ClassesPath+#AOTRootPath+classStr(PriceDisc));
    addTreeNodeToProjectNode(treenode);

}

In the same way you can also create a private project, simply replace the occurrences of Shared by Private.

The created project looks like this:

Sceenshot


 
 
 

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();
    }
}

 
 
 

List all modified objects from current layer, which are not added to versioncontrol

Using the SysModel* tables, you can browse the AOT to certain objects or their properties in Dynamics AX. I've posted an example already here.

The following job is an extension of the above posting and lists all objects that have been changed in the current layer and still were not added to version control.


 
 
 

List all modified objects from current layer

To browse the AOT for particular objects, you can use the TreeNode class. I've already posted some examples in the past.

In Dynamics AX 2012, a new option has been added, and although there are now some tables that begin with SysModel*. You can also use these tables to browse the AOT objects/properties.

An example of such a query is the following job, which returns (unsorted) all objects that have been modified in the current layer.


 
 
 

Get all tables, where a particular property has a specific value

The following job lists all tables where a particular property - in the example the property ModifiedBy is requested - has a specific value.

In macro #Properties you find another possible properties of AOT objects, so you can use the job also to query other properties.

static void findTablesWithSpecificProperty(Args _args)
{
    TreeNode treeNodeTables;
    TreeNode treeNode;
    str prop;
    str properties;

    #aot
    #Properties;

    treeNodeTables = TreeNode::findNode(#TablesPath + #AOTRootPath);
    treeNodeTables = treeNodeTables.AOTfirstChild();

    while(treeNodeTables)
    {
        properties      = treeNodeTables.AOTgetProperties();
        prop = Global::findProperty(properties,#PropertyModifiedBy);

        if(prop == "yes")
        {
            info(treeNodeTables.AOTname());
        }

        treeNodeTables = treeNodeTables.AOTnextSibling();
    }
}

 
 
 

Add object nodes to a shared project through code

Find below a short example, how to add object nodes to a shared project through code.

static void AddNodeToSharedProject(Args _args)
{
    projectNode projectNode;
    TreeNode treeNode;
    #AOT
    #AOTExport

    projectNode    = infolog.projectRootNode();
    projectNode    = projectNode.AOTfindChild(#expProjectShared);
    projectNode    = projectNode.AOTfindChild('MyProject');
   
    // Add objects
    treenode = TreeNode::findNode(#TablesPath+'\\'+tableid2name(tablenum(CustGroup)));
    projectNode.addNode(treenode);

    treenode = TreeNode::findNode(#TablesPath+'\\'+tableid2name(tablenum(VendGroup)));
    projectNode.addNode(treenode);
   
    treenode = TreeNode::findNode(#ClassesPath+'\\'+classStr(PriceDisc));
    projectNode.addNode(treenode);
}

The so modified Project will look like this:

Screenshot


 
 
 

 

 
 
 
Posts of the actual month
März 2024
MoTuWeThFrSaSu
 123
45678910
11121314151617
18192021222324
25262728293031
 
© 2006-2024 Heinz Schweda | Imprint | Contact | German version | Mobile 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.