Monday, October 23

AX 2012 - Get User Roles Associated with current user in X++ code

Following line of code fetch all roles associated with current login user in microsoft dynamics ax 2012.



static void Getuserroles(Args _args)
{
    SecurityRole role;
    SecurityUserRole userRole;
    UserInfo userInfo;
    ;
    while select role
        exists join userRole
            where role.RecId == userRole.SecurityRole &&
                       userRole.User == curUserId()
    {
        info(strFmt(“%1 – %2”, role.Name,curUserId()));
    }
}

No comments:

Post a Comment

Popular Posts