Skip to main content



No record found.

Microsoft Dynamics AX forum
Suggested answer

Rename menuItem with x ++ in dynamics 365.

Posted on by 55

Hello everyone,

I have a problem when trying to change the name of a MenuItem in Dynamics 365, I am using 
the code with which I made this change in Dynamics Ax 2012 but when compiling it says
that it is already obsolete, the code I use is this:

TreeNode    objTreeNode;
        objTreeNode= TreeNode::findNode(TreeNode::findNode(strfmt(@"\Menu Items\Display\%1",menuItemName)).treeNodePath());

        if (objTreeNode)
            objTreeNode.AOTsetProperties("PROPERTIES\n Label  #" + newLabel + "\n ENDPROPERTIES\n");

I would like to know how I can make this change in Dynamics 365, thank you to anyone
who can help me.

Thank you.

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,148 on at
    RE: Rename menuItem with x ++ in dynamics 365.

    First of all, you should not change the metadata on the fly. You are not supposed to modify a computer program while it's being executed. That approach is doomed to fail. Instead you should use the possibility to show/hide things, and impact captions and other properties during execution time.

    For example if you have a menu item button on a form, you can change the name of the button in the form's init method.


    Also you should consider how you will be able to support the users, if things are named differently for each user. How can you understand the customer's issue when they report a problem to you? Instead of letting each user identify the same things with different names, you should educate the users to identify the things with common names.

    And if you still have scenarios where some users should access some data with button "A", and other users with button "B", just create two buttons and use security setup to show the correct button to each user, just like ievgen suggested.

  • Martin Dráb Profile Picture
    Martin Dráb 225,862 Super User on at
    RE: Rename menuItem with x ++ in dynamics 365.

    We had a similar discussion in your previous thread, Modify Label in Dynamics 365 with x++, and I'm still waiting for your explanation of what business problem are you trying to solve.

    Also notice my suggestions there.

  • RE: Rename menuItem with x ++ in dynamics 365.

    Hello Sukrut,

    Sorry, I think he explained a little confusing, I hope the following is a little clearer.

    1. I have a table where I create Records as follows:


            A                        My text A

            B                        My text B

    2. I have a MenuItemDisplay with name MyMenuItemDisplayA and I want your Label Property to be the value found in LABEL TEXT, there may also be other

      objects that LABEL TEXT must have as Label Property.

      This must be dynamic, because the user can Edit the LABEL TEXT in the table at any time.

    I'm looking for a solution because according to a previous answer I can not edit the Label of a LabelId.

  • Suggested answer
    Mea_ Profile Picture
    Mea_ 60,274 on at
    RE: Rename menuItem with x ++ in dynamics 365.

    Hi Victor H. Cortes,

    There is a solution to your issue without a single line of code. Just create 2 menu items "Sales*" and "Purchase*" that will open same form\class and give access via security to one that user should see and hide another.

  • RE: Rename menuItem with x ++ in dynamics 365.

    Yes, it is different for each user.

  • RE: Rename menuItem with x ++ in dynamics 365.

    Hello Martin,

    I need to change the label property of a MenuItem, so that it is dynamic according to the user. This is because users identify objects with different names. Example for the User The label is "Sales" and for user B the label is "Purchases".

  • Martin Dráb Profile Picture
    Martin Dráb 225,862 Super User on at
    RE: Rename menuItem with x ++ in dynamics 365.

    It won't work.

    What business requirement are you trying to implement with this technical solution? Maybe we can suggest a different approach that will be possible.

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .


André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 288,513 Super User

Martin Dráb Profile Picture

Martin Dráb 225,862 Super User

nmaenpaa Profile Picture

nmaenpaa 101,148


Featured topics

Product updates

Dynamics 365 release plans