Get Current User's Security Roles
To get Current user information, you can use getGlobalContext.userSettings client API reference.
Sometimes business wants to perform some business logic based on particular user's security role, in that case you can get security role of current user and perform your logic using below client API reference.
You can follow following link for more details about current user properties:
Current User Properties
Current User Properties
Following is the example of how you can restrict your business logic to particular user's by getting their security roles:
getCurrentUserSecurityRole: function(executionContext) {
var formContext = executionContext.getFormContext();
var roles = Xrm.Utility.getGlobalContext().userSettings.roles;
roles.forEach(function(item) {
if (item.name.toLowerCase() === "Your Security Role Name") {
//perform your business logic here!
}
}
});
}
Comments
Post a Comment