Dynamics AX Blog - Dynamics AX 2012 - aot

RSS-Feed of this version
Search project names for a specific stringTo 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 versioncontrolUsing the SysModel* tables, you can browse the AOT to certain objects or their properties in Dynamics AX. I've posted an example already here. |
List all modified objects from current layerTo browse the AOT for particular objects, you can use the TreeNode class. I've already posted some examples in the past. |
Get all tables, where a particular property has a specific valueThe following job lists all tables where a particular property - in the example the property ModifiedBy is requested - has a specific value. 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 codeFind 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:
|
|
|
|
|
|
|

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: