将现有显示菜单项添加到用户收藏夹
Add existing display menu item to user favorites
基于 this Code,我构建了一个功能的基础,为每个用户提供一组预定义的收藏夹。
然而,此特定代码会为每个用户的每个收藏夹创建一个新的 AOT 元素。我想手动配置菜单项并简单地用脚本分发它们。
我如何(在 X++ 中)获取对现有 \Menu Items\Display
节点的引用并将其添加到 Menu
[=24= 的 object ]?
这是我目前拥有的:
MyFavorites obj = new MyFavorites();
Menu menuNode;
MenuFunction mf;
TreeNode treeNode;
info("Applying favorites...");
menuNode = obj.getOrCreateRoot();
if (menuNode == null) return;
treeNode = menuNode.AOTfindChild("Administrator");
if (!treeNode)
{
menuNode.addSubmenu("Administrator");
treeNode = menuNode.AOTfindChild("Administrator");
info("Created submenu");
}
else info("Found submenu");
menuNode = treeNode;
// Here I need help. I don't want to recreate all these AOT nodes every time the script is run.
mf = new MenuFunction("Fav_AllUsers",MenuItemType::Display);
mf.AOTsave();
menuNode.addMenuitem(mf);
这是我写的一个快速作业,可以将 "SalesTable" 菜单添加到您的收藏夹。
Also here's a link that shows how to copy favorites between users
需要注意的是 table SysPersonalization
,它存储数据块,因此您必须使用 object UserMenuList
、Menu
,或者 table 来完成你想要的。不过,这应该可以帮助您入门。
static void Job4(Args _args)
{
TreeNode treeNode;
TreeNode menuToAdd = TreeNode::findNode(@"\Menu Items\Display\SalesTable");
TreeNodeIterator iterator;
UserMenuList userMenu;
Menu menuNode;
treeNode = infolog.userNode();
iterator = treeNode.AOTiterator();
treeNode = iterator.next();
if (treeNode)
{
userMenu = treeNode;
// find 'My Favorites' user menu;
treeNode = userMenu.AOTfindChild("@SYS95713");
// Note menuNode is a different object than userMenu
menuNode = treeNode;
menuNode.addMenuitem(menuToAdd);
}
}
基于 this Code,我构建了一个功能的基础,为每个用户提供一组预定义的收藏夹。
然而,此特定代码会为每个用户的每个收藏夹创建一个新的 AOT 元素。我想手动配置菜单项并简单地用脚本分发它们。
我如何(在 X++ 中)获取对现有 \Menu Items\Display
节点的引用并将其添加到 Menu
[=24= 的 object ]?
这是我目前拥有的:
MyFavorites obj = new MyFavorites();
Menu menuNode;
MenuFunction mf;
TreeNode treeNode;
info("Applying favorites...");
menuNode = obj.getOrCreateRoot();
if (menuNode == null) return;
treeNode = menuNode.AOTfindChild("Administrator");
if (!treeNode)
{
menuNode.addSubmenu("Administrator");
treeNode = menuNode.AOTfindChild("Administrator");
info("Created submenu");
}
else info("Found submenu");
menuNode = treeNode;
// Here I need help. I don't want to recreate all these AOT nodes every time the script is run.
mf = new MenuFunction("Fav_AllUsers",MenuItemType::Display);
mf.AOTsave();
menuNode.addMenuitem(mf);
这是我写的一个快速作业,可以将 "SalesTable" 菜单添加到您的收藏夹。
Also here's a link that shows how to copy favorites between users
需要注意的是 table SysPersonalization
,它存储数据块,因此您必须使用 object UserMenuList
、Menu
,或者 table 来完成你想要的。不过,这应该可以帮助您入门。
static void Job4(Args _args)
{
TreeNode treeNode;
TreeNode menuToAdd = TreeNode::findNode(@"\Menu Items\Display\SalesTable");
TreeNodeIterator iterator;
UserMenuList userMenu;
Menu menuNode;
treeNode = infolog.userNode();
iterator = treeNode.AOTiterator();
treeNode = iterator.next();
if (treeNode)
{
userMenu = treeNode;
// find 'My Favorites' user menu;
treeNode = userMenu.AOTfindChild("@SYS95713");
// Note menuNode is a different object than userMenu
menuNode = treeNode;
menuNode.addMenuitem(menuToAdd);
}
}