Wednesday, June 3, 2009

Checking table access from code

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


boolean CheckSecurityTable(TableId myTableId)

{ SysDictTable SysDictTable;
;
SysDictTable = new SysDictTable(myTableId);
if(SysDictTable.rights()<AccessType::View)

return false;


return true;
}


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

if(hastableaccess(tablenum(SalesLine),AccessType::View))
return true;


Something similar, but now with a menuitem:


boolean CheckSecurityMenu(MenuName myMenuName)

{ SysDictMenu SysDictMenu;
;
SysDictMenu = SysDictMenu::newMenuItem(myMenuName,MenuItemType::Display);
if(SysDictMenu.rights()<AccessType::View)

return false;


return true;
}



Greetz,


Willy

2 comments:

  1. It is always brilliant & easy way of check table access using code. It is quite easy & also helps in saving many time as compared to check the table manually.

    ReplyDelete
  2. ERPTREE Offering Oracle fusion HCM online training, Oracle Fusion SCM Online Training, Oracle fusion financials online
    training, Oracle fusion hcm training, Oracle fusion scm training, Oracle fusion financials training, Oracle fusion dba online training in Hyderabad, Bangalore,Gurgon, Noida, India, Dubai, UAE, USA, Kuwait, UK, Singapore, Saudi rabia, Canada, Delhi, Chennai, Kolkata, Pune, Mumbai, Ahmedabad.


    Oracle Fusion HCM Training

    ReplyDelete