How to Identify the current user group for the current user logon to AX using X++?

Please help

How to Identify the current user group for the current user logon to AX using X++?

Best Regards,

Geetika

Hi Geetika,

The user can belong to multiple user groups. Use the following piece of code to find all the user group that the user belongs to.

static void UserGroupIdForCurrentUser(Args _args)

{

UserGroupList groups;

UserInfo userInfo;

SysCompanyUserInfo sysCompanyUserInfo;

;

select * from userInfo where userInfo.id == curuserid();

info(strfmt(“You have login by this %1 user id and alias name is %2”,curuserid(),userInfo.networkAlias));

info(“You belong to following user groups”);

select VendAccount from sysCompanyUserInfo where sysCompanyUserInfo.UserId == curuserid();

while select groups where groups.userId == curuserid()

{

info(groups.groupId);

}

}

Regards,

Raghavendra.