基于this Code我构建了一个函数的基础知识,为每个用户提供一组预定义的收藏夹。
但是,此特定代码会为每个用户的每个收藏夹创建一个新的AOT元素。我想手动配置菜单项,只需用脚本分发它们。
我如何(在X ++中)获取对现有\Menu Items\Display
节点的引用并将其添加到Menu
类的对象?
这是我到目前为止所做的:
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);
答案 0 :(得分:2)
这是我编写的一份快速工作,其中添加了" SalesTable"菜单到你最喜欢的。
Also here's a link that shows how to copy favorites between users
需要注意的是表SysPersonalization
,它存储了一大块数据,因此您必须使用对象UserMenuList
,Menu
或该表实现你想要的。这应该可以让你开始。
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);
}
}