Pages

Thursday, 2 January 2014

Hide Ribbon Button based on user security role

Hiding button in the CRM ribbon based current user security role.

function UserRole(){
var roles= new Array();
 roles=Xrm.Page.context.getUserRoles().toString().split(',');
 for(var i=0;i<roles.length;i++){
 if(roles[i]=="f16a3219-3756-e211-8c2e-000c29e7d817"){ //guid of my security role
  var btnRunWorklfow=top.document.getElementById("incident|NoRelationship|Form|new.incident.Button1.Status-Large");
  btnRunWorklfow.style.display='none';
  }
else{
var btnRunWorklfow=top.document.getElementById("incident|NoRelationship|Form|new.incident.Button6.CaseState-Large");
  btnRunWorklfow.style.display='none';
  }
 }
 }

No comments:

Post a Comment