Home > Dynamics Ax > Creation of MenuItem using X++ code

Creation of MenuItem using X++ code

After a long break, again I Started my blogging       Sad    
Here you can find the sample code for, creation of new Menu Item using X++ code.    Tongue out
static void CreateMenuItem(Args _args)
    TreeNode    treeMenuItem;
    TreeNode    treeDisplayMenu;
    TreeNode    treeMenus;
    TreeNode    treeMenu;
    str               myProp;
    treeMenuItem    = TreeNode::findNode(#MenuItemsDisplayPath);
    treeDisplaymenu = TreeNode::findNode(#MenuItemsDisplayPath + "\" + "SalesTable");
    myProp  = treeDisplaymenu.AOTgetProperties();
    if (treeDisplayMenu)
        treeDisplayMenu = treeMenuItem.AOTfindChild(‘MySALESTABLE’);
        myProp = "PROPERTIESn Object  #" + ‘SALESTABLE’ + "n  Label  #" + ‘MySalesTable’ + "n ENDPROPERTIESn";
        //treeDisPlayMenu.AOTsetProperties("PROPERTIESn Object  #" + ‘SALESTABLE’ + "n  Label  #" + ‘SALESTABLES’ + "n ENDPROPERTIESn");
Suggestion: we can set the properties one by one also like the following:
           myProp = setProperty(myProp,’Name’,’MyNewMenuItem’);
           myProp = setProperty(myProp,’Label’,’MyNewMenuItem’);
Here first we will change the Property Name and we will chnage another property Label
This will be useful, when do u want copy the properties of existing item to newly created items using X++.  Sun
Categories: Dynamics Ax
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: