How to Check Table Access for User in Ax


If you need to check if the current user has access to a certain table in Ax, this little job will help you out:

staticvoidTableAccessView(Args _args)
{
SysDictTableSysDictTable;
TableIdmyTableId= 'Insert Tableid Here';
    ;

SysDictTable = newSysDictTable(myTableId);
if(SysDictTable.rights()<AccessType::View)
    {
info("false");
    }
else
    {
info("true");
    }
}

If you like your code a little more condensed, you could always use the built-in function hastableaccess. For example:

staticvoid TableAccessView1(Args _args)
{
if(hastableaccess(tablenum(CustAging),AccessType::View))
    {info("true");}
else
    {info("false");}
}

Something similar, but now with a menuitem:

staticvoidMenuItemAccessView(Args _args)
{
SysDictMenuSysDictMenu;
;
SysDictMenu = SysDictMenu::newMenuItem('AbatementCertificate_IN',MenuItemType::Display);
if(SysDictMenu.rights()<AccessType::View)
    {
info("false");
    }
else
    {
info("true");
    }
}

Related Posts

Previous
Next Post »

Thanks for comments.....