Based on security role, hiding the ribbon buttons
Create approve button using ribbon work bench, it should visible only who having user administrator role, on click on approve button change the status to approve.
We need to add the ribbon button. if u dont no u can click the below link to how to create the ribbon buttons https://www.blogger.com/blog/post/edit/8626627912470024302/3389361209653815671?hl=en-GB
After adding the button to form we need to write the JavaScript and trigger on the form load.
simple code to check for the securtiy
function SecurityCheck() {
var flag = false;
var userRoles = Xrm.Utility.getGlobalContext().userSettings;
if (Object.keys(userRoles.roles._collection).length > 0) {
for (var rolidcollection in userRoles.roles._collection) {
var currentUserRoles = Xrm.Utility.getGlobalContext().userSettings.roles._collection[rolidcollection].name;
if (currentUserRoles.toLowerCase() == "useradministrator") {
flag = true;
break;
}
}
}
return flag;
}
By writng above and trigger on the form on save then you can achieve this
Comments
Post a Comment