Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 82002

Subgrid ribbon button issue

$
0
0

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;                                             
           }
           elseif ((currentUserRoles != "System Administrator"&& effectiveStage === 803850006) ){
            isButtonEnabled = false;             
           }      
        }          
    }    
    return isButtonEnabled;    
}

Viewing all articles
Browse latest Browse all 82002

Latest Images

Trending Articles



Latest Images