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 post is locked for comments