Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Axapta User Permission

Im working on a report in AX2009 that will show what users have what permission, my question is,

how can i find through code (in x++) if user1 has got permission to post movement journals ?

thanks

like image 598
Arifeen Ahmed Avatar asked May 29 '14 16:05

Arifeen Ahmed


1 Answers

Have a look at the SecurityKeySet class.
For example, to check whether the user has access to the menu item InventJournalPost:

SecurityKeySet userRights;
MenuFunction   inventJournalPostFunction;
AccessType     functionAccess;
boolean        canPost;
;

userRights = new SecurityKeySet();
userRights.loadUserRights(curuserid()); // or any other user ID

inventJournalPostFunction = new MenuFunction(
    menuitemactionstr(InventJournalPost),
    MenuItemType::Action);

functionAccess = userRights.menuItemAccess(
    inventJournalPostFunction.name(),
    AccessRecordType::MenuItemAction);
canPost = (functionAccess >= inventJournalPostFunction.neededAccessLevel());

info(strfmt("User %1 post inventory journals", canPost ? "can" : "can not"));
like image 181
DAXaholic Avatar answered Sep 28 '22 04:09

DAXaholic