In this post I am going to explain how you will hide and show the Ribbon/Command buttons based on logged in user security rule.
I have one Delete button on one Custom entity(Employee). I have to hide this button based on logged in user security roles, for it I used the Enable Rule.
Create the java script with function as below.
function HideLeadQualifyButtonBasedOnRoles()
{
let hasRole = false;
let roles = Xrm.Utility.getGlobalContext().userSettings.roles;
roles.forEach(x =>
{
if (x.name === "Area Manager" || x.name === "Sales Manager")
{
hasRole = true;
return;
}
});
if (hasRole === true) {
return true;
} else {
return false;
}
}
1. Open your solution into your ribbon workbench => Select your button => click on Enable Rule => Add Step
No comments:
Post a Comment