This post is machine-translated. The original post in german language can be found here.

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

These post applies to following version:
Dynamics AX 2012

D365 12/28/2019 10:04 | #1

Informative blog. Thanks for sharing.

 
 

 

 
 
 
Posts of the actual month
November 2024
MoTuWeThFrSaSu
 123
45678910
11121314151617
18192021222324
252627282930 
 
© 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.