Question (related to post about the DEV_CreateNewProject tool for AX):
So could create ConfigKeys Macro and I wanted, and could throw them into the project that was created, but I can not throw them within their respective nodes, so they are loose in the project, you can help me put them within your nodes?
To summarize, Gustavo wanted to create some AOT elements from code (specifically, configuration keys and macros), and add them to a new project into respective groups, similar to how it is done in DEV_CreateNewProject tool.
I wrote a small job that does that, and can be downloaded from my OneDrive. The code is also pasted and explained below:
static void Tutorial_CreateProjWithGroupAndElement(Args _args) { ProjectListNode treeNodeProject; ProjectNode upgradeNode; ProjectGroupNode child; MacroBuild macro; #AOT str projName = @"Project01"; str groupName = @"macroGrp"; str macroName = @"macro01"; treeNodeProject = SysTreeNode::getPrivateProject(); treeNodeProject.AOTadd(projName); upgradeNode = treeNodeProject.AOTfindChild(projName); upgradeNode = upgradeNode.getRunNode(); upgradeNode.AOTadd(groupName); child = upgradeNode.AOTfindChild(groupName); child.projectGroupType(GroupNodeType::Macros); macro = new MacroBuild(macroName, true); macro.addSource(@"isConfigurationkeyEnabled(configurationkeynum(WMSAdvanced))"); macro.save(); child.addUtilNode(UtilElementType::Macro, macroName); upgradeNode.AOTsave(); }
- SysTreeNode class is used to retrieve the object for the root of the Private projects node. This class contains a number of interesting methods for anyone who wants to navigate and manage AOT nodes
- Standard AOTadd and AOTfindChild methods are used for first creating and then loading the contents of the node into a TreeNode object for processing.
- getRunNode is used on the project node so that it is not just loaded for processing, but also opened in a new window to show the result to us after executing the job
- MacroBuild class is used to creating new Macros, and is similar to a ClassBuild that I described previously
- addUtilNode is the key method Gustavo was missing, and allows to add the macro created to the project group node.
- AOTsave() is used to persist all the changes done to the project as well as the new macro.
You can see the results immediately after executing the job.
No comments:
Post a Comment
Please don't forget to leave your contact details if you expect a reply from me. Thank you