Hi Sherwin,
Here there is a possibility that in two different modules named X and Y there are some common Menu items.
In our case we want to make sure that only the Module that we want to appear comes up, and the other Module
is not visible even if it has some Menu Items that are common with the visible Module.
As we know there is already an option to customize the navigation pane (which shows or hides modules).
So the code below will achieve this functionality :
*//Code for Hide Modules Functionality
public static void HideModulesForRole()
{
container cont_navButtons;
container cont_UserRoles;
TreeNode menunode;
TreeNode mainmenunode;
TreeNodeIterator menuitemiter;
str aotName;
int i = 1;
int j = 1;
int loc;
boolean isAdmin = false;
SecurityRole securityRole;
SecurityUserRole securityUserRole;
#AOT
#define.Zero('0')
#define.MainMenuLocation('\\Menus\\MainMenu')
//Fetch all roles for currently logged in User and insert in variable cont_UserRoles.
while select securityUserRole
join securityRole
where securityUserRole.User == curUserId()
&& securityRole.RecId == securityUserRole.SecurityRole
{
cont_UserRoles += securityRole.AotName;
if (securityRole.AotName == '-SysAdmin-')
{
isAdmin = true;
}
}
if (!isAdmin && conFind(cont_UserRoles, 'YourRoleName'))
{
mainmenunode = TreeNode::findNode(#MainMenuLocation);
menuitemiter = mainmenunode.AOTiterator();
menunode = menuitemiter.next();
while(menunode != null)
{
aotName = menunode.AOTname();
if(aotName == 'Home' || aotName == 'YourMenuName')
{
// Prefix 1 to show module
cont_navButtons = conIns(cont_navButtons, j, '1' + aotName);
}
else
{
// Prefix 0 to hide module
cont_navButtons = conIns(cont_navButtons, j, '0' + aotName);
}
j++;
menunode = menuitemiter.next();
}
// Hide Modules with 0 as prefix
infolog.navPane().setCurrMenuButtons(cont_navButtons);
}
}
So this static method needs to be called from the startupPost method of the Info class.