Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :

Get path for menu item in X++

M Anas Khan Profile Picture M Anas Khan 1,424

Purpose:

This post describes how we can get the full menu path of a given menu item.

Product:

Dynamics AX 2012

Code:

static void MAKMenuItemPath(Args _args)
{
    #TreeNodeSysNodeType
    #Properties
    #AOT

    TreeNode menuItemNode = TreeNode::findNode(@"\Menu Items\Display\HRMParameters");
    TreeNode menuNode;
    xRefPaths xRefPaths;
    xRefReferences xRefReferences;
    TreeNode parentNode;
    str path;
    xRefPaths = xRefPaths::find(menuItemNode.treeNodePath());

    while select xRefReferences
        where xRefReferences.referencePathRecId == xRefPaths.RecId
            && xRefReferences.Reference == XRefReference::Read
    {
        path = SysLabel::labelId2String(menuItemNode.AOTgetProperty(#PropertyLabel));
        menuNode = TreeNode::findNode(xRefPaths::findRecId(xRefReferences.xRefPathRecId).Path);

        if(menuNode && SysTreeNode::path2ApplObjectType(menuNode.treeNodePath()) == UtilElementType::Menu)
        {
            parentNode = menuNode.AOTparent();

            while(parentNode && parentNode.treeNodePath() != #MenusPath)
            {
                path = SysLabel::labelId2String(parentNode.AOTgetProperty(#PropertyLabel))  + " > " + path;
                parentNode = parentNode.AOTparent();
            }

            info(path);
        }
    }
}

This was originally posted here.

Comments

*This post is locked for comments