Consider a real time scenario, where we have to send alerts to all user in certain Role In Dynamics.
For this purpose we have to loop through all user in certain role.
User, roles and role assignment are done three tables, these tables are hidden in AOT.
These table are
UserInfo : This table holds all User Ids In Dynamics Ax 2012.
SecurityRole : This table hold all Security Roles, In this table has two important fields “Name” which is descriptive and second one is AOTName. If you get the current customer assigned role using then this AOTName will be return.
SecurityUserRole: This table holds many to many relation with security and User.
For below snippet, I loop through all user assigned in Sales Representative.
staticvoid RoleUSerID(Args _args)
{
UserInfo userInfo;
SecurityUserRole securityUserRole;
SecurityRole Roles;
whileselect userInfo
join securityUserRole
where securityUserRole.User == userInfo.Id
join Roles where Roles.RecId == securityUserRole.SecurityRole
&& Roles.AotName ==”TradeSalesRepresentative”
{
info(userInfo.Id);
}