How to Programmatically Create a Project for Objects in a Given Layer


You may want to create an AX project that contains all of the application elements that exist in a given layer.  For example, if you need to recreate the VAR layer *.aod file, you will need to pull all of the application elements in the VAR layer into a project, export the project to an xpo, delete the VAR *.aod file and finally log into the newly created VAR *.aod file import the xpo.  When you import the xpo all of the application elements can be recreated in the new *.aod file.  The code in this document demonstrates how to do this. 


When the X++ code in this example is added to a job in the AOT and executed, the code will create a  private project called VarLayerChanges.  The VarLayerChanges project will contain all of the elements that exist in the VAR layer.  If you would like to create a project for a different layer, change the string 'VarLayerChanges' to the layer you need it for, for example 'CusLayerChanges'.  Then change the enum UtilEntryLevel::var to the different layer, for example UtilEntryLevel::cus.


TreeNode treeNode = infolog.projectRootNode();
ProjectNode projectNode;
UtilElements utilElements;

treeNode = treeNode.AOTfirstChild();

projectNode = treeNode.AOTfindChild('VarLayerChanges');
projectNode = projectNode.getRunNode();

while select utilElements WHERE utilElements.utilLevel == UtilEntryLevel::var


Need more help?

Expand your skills
Explore Training
Get new features first
Join Microsoft Insiders

Was this information helpful?

Thank you for your feedback!

Thank you for your feedback! It sounds like it might be helpful to connect you to one of our Office support agents.