How to using code find the menu label of Menus【X++】

时间:2021-10-14 16:23:01
// VAR Changed by Xie Yu Fan.Fandy 谢宇帆
static void XIE_FindMenu(Args _args)
{
    Dialog      dlg     = new Dialog("搜索菜单名称");
    DialogField dlgName = dlg.addField(typeId(name));
    name        menuName;

    void findMenu(SysDictMenu _sysDictMenu, name _MenuName, str _path = "" )
    {
        SysMenuEnumerator   me;
        ;
        if (_sysDictMenu.isMenuReference() || _sysDictMenu.isMenu())
        {
            _path   = (_path ? _path + "\t" : _path) + _sysDictMenu.label();
            me      = _sysDictMenu.getEnumerator();
            while (me.moveNext())
            {
                findMenu(me.current(), _MenuName, _path);
            }
        }
        else
        {
            if( _sysDictMenu.label() like "*"+_MenuName+"*")
            {
                info(_path + "\t" + _sysDictMenu.label());
            }
        }
    }
;
    dlg.doInit();
    dlgName.value("保存月底库存");

    if( !dlg.run())
        return;
    menuName = dlgName.value();
    if(menuName)
    {
        findMenu(SysDictMenu::newMainMenu(), menuName);
    }
}

 How to using code find the menu label of Menus【X++】