Hi,
I've been asked to programmatically disable unwanted menu from the NavPane. My code seems to work fine when running for the current company but AX hangs with an exception when trying to do that accross compagnies. The code is :
static void Job3(Args _args)
{
container curButtons;
container newButtons;
int i;
int j;
str value;
CompanyInfo c;
;
// if (UserInfoHelp::userInUserGroup(curuserid(),"admin")) return;
while select crosscompany * from c where c.dataAreaId!=curext()
{
Info(c.dataAreaId);
changecompany(c.dataAreaId)
{
conDel(curButtons,1,conLen(curButtons));
conDel(newButtons,1,conLen(newButtons));
// Menu modules
curButtons = infolog.navPane().getButtons();
j=1;
for(i=1;i<conLen(curButtons);i+=2)
{
value=conPeek(curButtons,i);
switch(value)
{
// If activated, disable
case "1smmCRMSeries","1Invent","1Req","1Prod","1TrvExpense":
value="0"+substr(value,2,strlen(value)-1);
break;
}
// Updated buttons
newButtons=conIns(newButtons,j,value);
j++;
}
// Save changes
infolog.navPane().setCurrMenuButtons(newButtons);
}
}
}
Could I change something to make it work or is it just not possible ? I suspect my code might sort of work with a single company but doesn't proceed exactely as it should (looks similar thought to what I have understood from sysNavPaneOptionsDialog).
Thanks in advance.