RE: Show/Hide Reactivate buton on Case form based on user Role
Hi Alaa Ramadan,
Please change code to this to have a try:
//
// Hide the Activate button and the Deactivate button when user has Salesperson security role
//
function hideActivateAndDeactivateRibbonButtons() {
//
// default return value to true. Show buttons
//
var value = true;
//
// Set variable with SalesPerson security role GUID
//
var constSalesPersonGuid = "74E3A3A3-E6F3-4B97-A045-A557B1660293";
//
// Get the Current User's Security Roles
//
// D365 v9
var userRoles = Xrm.Utility.getGlobalContext().userSettings.securityRoles;
//
// loop through roles and look for SalesPerson guid
//
for (var i = 0; i < userRoles.length; i ) {
if (userRoles[i].toUpperCase() == constSalesPersonGuid.toUpperCase()) {
//
// Hide Activate button and the Deactivate button
//
value = false;
break;
}
}
return value;
}
And please make sure the enable rule is tied to the command.