Bhubaneswar, Odisha, India
+91-8328865778
support@softchief.com

Hide show command button using JavaScript in power apps

Hide show command button using JavaScript in power apps

use below code in Enable Rule.

var MyJS = MyJS || {};
MyJS.SecurityCheck = function () {
    // enable rule client side execution custom rules
    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()=="salesperson")
           {
               flag=true;
               break;
           }
        }
    }
    return flag; 
  };