Hello,
I am hiding + button on subgrid ribbon based on condition(Security role + BPF stage) . The problem is that the only way to show or hide + button on a subgrid ribbon is to save a form. Please let me know what I am missing in my JS code. Thank you.
function hideAddNewButton(primaryContext) {
debugger;
var isButtonEnabled = true;
var effectiveStage = primaryContext.getAttribute("statuscode").getValue();
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 == "System Administrator" )|| (currentUserRoles != "System Administrator" && effectiveStage != 803850006)){
isButtonEnabled = true;
}
else if ((currentUserRoles != "System Administrator" && effectiveStage === 803850006) ){
isButtonEnabled = false;
}
}
}
return isButtonEnabled;
}