let roles = Xrm.Utility.getGlobalContext().userSettings.roles;
Example:
Requirements:
Read the logged in user Security Roles and check the user is having Basic User and Sales manager roles, If have then show the Contact Job Title field otherwise hide it.
Requirements:
Read the logged in user Security Roles and check the user is having Basic User and Sales manager roles, If have then show the Contact Job Title field otherwise hide it.
function checkRoles(executionContext)
{
let formContext = executionContext.getFormContext();
let hasRole = false;
let roles = Xrm.Utility.getGlobalContext().userSettings.roles;
// ["AB Roles", "Sales Manager", "System Administrator"]
roles.forEach(x => {
if (x.name === "Basic User" || x.name === "Sales Manager") {
hasRole = true;
return;
}
});
if (hasRole === true) {
formContext.getControl("jobtitle").setVisible(true);
} else {
formContext.getControl("jobtitle").setVisible(false);
}
}
No comments:
Post a Comment