Arifeen Ahmed
Arifeen Ahmed

Reputation: 118

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

Upvotes: 5

Views: 1380

Answers (1)

DAXaholic
DAXaholic

Reputation: 35358

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"));

Upvotes: 6

Related Questions