Thursday, March 10, 2016

To get the list of Roles assigned to users in AX 2012

Applied on: 
Microsoft Dynamics® Ax 2012,Ax 2012 R2,Ax 2012 R3.
This article is for both  Ax Technical  & functional consultants including Administrators.

About this article: 
Some times we need the list of roles assigned to particular user or for all is very difficult to check each user roles.

we can fetch the required data from Two tables with the help of a small job.
Tables :  SecurityRole & SecurityUserRole

//Naresh.D  01-05-2014
static void SecurityRole(Args _args)
  SecurityRole          securityRole;
  SecurityUserRole     securityUserRole;
    while select RecId,name from securityRole   
    join securityUserRole   
    where securityRole.RecId == SecurityUserRole.SecurityRole   
    //&& SecurityUserRole.User == curUserId() //for current user roles
      info(strFmt("%1 - %2",SecurityUserRole.User,;