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

Thanks for comments.....

:)
:(
hihi
:-)
:D
=D
:-d
;(
;-(
@-)
:P
:o
:>)
(o)
:p
:-?
(p)
:-s
(m)
8-)
:-t
:-b
b-(
:-#
=p~
$-)
(y)
(f)
x-)
(k)
(h)
cheer