Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

How to get the name of form from menu Item?

(0) ShareShare
ReportReport
Posted on by 920

Hi,

I have privilege,I want to get from this privilege the name of menu Item in entry point and the form :

for the menu Item I develop this instruction:

//get the entry point from privilege:

 treeNode = TreeNode::findNode(#SecPrivilegesPath + #doubleAntiSlash + conPeek(privilegesCont, i) + #doubleAntiSlash + #EntryPoints);

 node = TreeNode.AOTfirstChild();

while (node)
{
 select  eukSecurityMenuItem where eukSecurityMenuItem.SecurableName == node.AOTgetProperty(#ObjectName);

}

I want to add the name of form from this menu Item :

2021.item.png

*This post is locked for comments

  • Verified answer
    Rustem Galiamov Profile Picture
    Rustem Galiamov 8,072 on at
    RE: How to get the name of form from menu Item?

    You can try to find object in different path:

        #AOT
         
        str find = "SalesTable";
        TreeNode menuItemFinded;
     
        menuItemFinded = TreeNode::findNode(#MenuItemsDisplayPath + "\\" + find);
            
        if (menuItemFinded)
           info(strFmt("Found menuitem %1", menuItemFinded.AOTgetProperty('Object')));
        else
        {
            menuItemFinded = TreeNode::findNode(#MenuItemsActionPath + "\\" + find);
            
            if (menuItemFinded)
                info(strFmt("Found menuitem %1", menuItemFinded.AOTgetProperty('Object')));    
            else
            {
                menuItemFinded = TreeNode::findNode(#MenuItemsOutputPath + "\\" + find);   
                info(strFmt("Found menuitem %1", menuItemFinded.AOTgetProperty('Object')));
            }
        }


  • BASMA Profile Picture
    BASMA 920 on at
    RE: How to get the name of form from menu Item?

    I dont understand your suggestion :

    root = TreeNode::findNode(@"\Menu Items"+"COSJournalTableCost"); i try this instruction but I get error:object not initialized

  • Suggested answer
    Rustem Galiamov Profile Picture
    Rustem Galiamov 8,072 on at
    RE: How to get the name of form from menu Item?

    You can check AOTgetProperty('ObjectType') and then use needed menu items path.

  • BASMA Profile Picture
    BASMA 920 on at
    RE: How to get the name of form from menu Item?

    Thanks for your reply, but I want to search menu item not only in display path but also in action and output

  • AXTechie2120 Profile Picture
    AXTechie2120 560 on at
    RE: How to get the name of form from menu Item?

    hi Basma,

    static void searchSubNodes(Args _args)

    {

     str         treeNodeNames;

     void searchSubNodes (TreeNode _treeNode)

     {

         if (!_treeNode)

             return;

         _treeNode = _treeNode.AOTfirstChild();

         while (_treeNode)

         {

             if (_treeNode.AOTfirstChild())

             {

                 searchSubNodes(_treeNode);

             }

             if (_treeNode.applObjectType())

             {

                 treeNodeNames += strfmt("%1 %2\n", _treeNode.treeNodeName(),_treeNode.AOTgetProperty('ObjectType'));

             }

             _treeNode = _treeNode.AOTnextSibling();

         }

     }

     ;

     searchSubNodes (TreeNode::findNode(@"\Menu Items"));

     info(treeNodeNames);

    }

    Try this and let me know if it works!

  • Suggested answer
    Rustem Galiamov Profile Picture
    Rustem Galiamov 8,072 on at
    RE: How to get the name of form from menu Item?

    Hi BASMA!

    Try this:

    TreeNode root = TreeNode::findNode(#MenuItemsDisplayPath + "\\SalesTable");
        
    info(root.AOTgetProperty('Object'));

    You can set your menuItem name instead of SalesTable

  • BASMA Profile Picture
    BASMA 920 on at
    RE: How to get the name of form from menu Item?

    no,

    I have privilege ,I want to browse the menu items to get the name of menu Items which is set in this privilege.

    I want alse to know the form that opend this menu item?

  • AXTechie2120 Profile Picture
    AXTechie2120 560 on at
    RE: How to get the name of form from menu Item?

    Hi,

    You want to call the menuitem name in your code. Am i Right?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans