I am working in Ax 2012. I have a question regards access and security. I have a Actionpane on the form. Within this actionPane there is a buttongroup and within that button group, there is a command button.
I do want to set the access of command button for the accountant role. Only Accountant role can view it, not anyone else.
Definitely don’t hard-wire employee IDs in code, as somebody suggested.
I believe you have to choose one of two ways:
Either you can map the command button to an access level, e.g. Delete.
Or you have to map the action as a new entry point, i.e. a menu item.
It’s unusual to do such things with command buttons, they’re typically used for something related to the form itself (closing, exporting to Excel…) which is not related to security or for manipulation of records (creating, deleting…) and that uses the table-level security.
NEVER hardcode security the way Mohd advised…!!! This will fail on the first audit of the system by external auditors… Microsoft did not invent that complex security system in AX 2012 for no reason so that you could start writing code structures like “if( curUserId() == “BOSS”) Object.visible(true);”.
And what if that employee will be fired and new one will come instead? Will you modify then? Will you modify the code in situation which should have been just a pure administrative settings change?
What if there will be 100 users who might need the same access level?? Will you write a huge “IF” statement like this: if (curUserId() == “ABC” || curUserId() == “DEF” || … ) ???
Sorry for being so offensive, but I haven’t said anything wrong…