最新消息:ww12345678 的部落格重装上线,希望大家继续支持。

获取X ++中菜单项的路径 / Get path for menu item in X++

网络文摘 William 1173浏览 1评论

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);
        }
    }
}
发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

网友最新评论 (1)

  1. 怎么没有用
    Danzel3年前 (2021-07-06)回复