Why do we need to get user security roles in Dynamics 365?
Consider a scenario where we need to perform a dedicated set of actions / operations based upon the current user’s security role. We can achieve this requirement with help of getGlobalContext.userSettings client API.
This client API returns the information about the current user settings in form of objects.
Xrm.Utility.getGlobalContext().userSettingsThe userSettings object provides following properties and a method.
- Open the Dynamics 365 CRM, deploy the above code in the “OnLoad” event of the entity form.
- Save and publish the deployed changes.
- Navigate to the Dynamics 365 record and open the console to verify the retrieved security roles.