Conditionally making your menu items visible on main menu, in D365fo x++
Conditionally making your menu items visible on main menu, in D365fo x++
a. Create a new class USMenuItemsVisibilityManager
b. Copy the following method, with proper documentation (don't change signature/anything else)
[SubscribesTo(classstr(SysMenuNavigationObjectFactory), staticdelegatestr(SysMenuNavigationObjectFactory, checkAddSubMenuDelegate)), Hookable(false)]
internal static void menuItemVisibilityHandler(SysDictMenu _rootMenu, SysDictMenu _subMenu, SysBoxedBoolean _subMenuVisibility)
c. And then just introduce the following code in the method:
if (_subMenu.isMenuItem())
{
var metaElement = _subMenu.GetMenuItemMetaElement();
if (metaElement != null)
{
vendParameters parmTable = VendParameters::find();
switch (metaElement.Name)
{
case menuItemDisplayStr(SHOWSSNCustInputTable): //give the name of your menu item here
_subMenuVisibility.value = pamrTable.DXCCustomerSKUOnHold == NoYes::Yes;
break;
}
}
}
Comments
Post a Comment