Tuesday 28 June 2016

Get user and their role in AX using X++

static void getUserandRole(Args _args)
{
    str roleName;
    SecurityRole securityRole;
    SecurityUserRole UserRole;
    SysUserInfo  userInfo;
    ;

    while select ID from userInfo
        order by id asc outer join UserRole
        where UserRole.User == userInfo.Id
            outer join securityRole
            where securityRole.RecId == UserRole.SecurityRole
    {
        roleName = SysLabel::labelId2String(securityRole.Name);
     
        info(strFmt("%1-%2",userrole.User,roleName));
    }
}

No comments:

Post a Comment