Check if the current user has a specific role or not via X++ in Microsoft Dynamics 365 F&O

 UserInfo userInfo;

SecurityUserRole securityUserRole; SecurityRole Roles; boolean allowed; select id from userInfo join SecurityRole from securityUserRole where securityUserRole.User == userInfo.Id join Roles where Roles.RecId == securityUserRole.SecurityRole && (Roles.AotName =='ROLENAME') && UserInfo.id == curUserId(); if(UserInfo.id == curUserId()) { Allowed = true; }

Comments

Popular posts from this blog

step 20 Update script for service model: AOSService on machine: CR-VM-Test-1

create movement journal through code in d365 FO x++