X++ code to modify/set properties of AOT elements in Dynamics AX


Hi,
 
Last week i came across a situation in which i want to change/set the properties of AOT element (MenuItems) using X++ code. so here is the sample code that will automatically update/set the properties of any AOT element.
 
Create a display MenuItem named as "Test". Initially the properties ViewUserLicense and
MaintianUserLicense are set to "None" as shown in the figure.
 
 
Now i want to change the value of these properties to "Task". Here is the sample code that will do the same.
 
Sample Code:
 
#AOT
str myProp;   
TreeNode treeMenuItem;
TreeNode treeDisplayMenu;
 
// set properties
treeMenuItem = TreeNode::findNode(#MenuItemsDisplayPath);
treeDisplaymenu = TreeNode::findNode(#MenuItemsDisplayPath +
"\\" + "Test");
treeDisPlayMenu.AOTsetProperties(
"PROPERTIES\n ViewUserLicense #" + 'TASK' + "\n MaintainUserLicense #" + 'TASK' + "\n ENDPROPERTIES\n");
treeDisplayMenu.AOTsave();
myProp = treeDisplaymenu.AOTgetProperties();
info(myProp);

 
 

 
Happy Coding :)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.