Quantcast
Viewing all articles
Browse latest Browse all 79901

Hide Options from Option Set based on Security role

Hi All , 

I need to hide some options from an option set ( Status Reason with schema name statuscode ) based on the security role . For example : if a user who has "Schedule Manager" security role and he/she opens a new opportunity , they should only be able to see some of the options from the Status Reason dropdown.

The code I wrote is :

<script>

var UserSecurityRoles= Xrm.Page.context.getUserRoles();
var userRoleName = "{997C4C00-BF39-E011-8DA3-1CC1DE72E35E}"


// Checking if Security Role Id found in User Security Roles

for (var x = 0; x < UserSecurityRoles.length; x++) {


if (UserSecurityRoles[x]==userRoleName)


{
Xrm.Page.getControl("statuscode").removeOption(100,000,003);

Xrm.Page.getControl("statuscode").removeOption(279640012);
Xrm.Page.getControl("statuscode").removeOption(100000026);
Xrm.Page.getControl("statuscode").removeOption(100000047);
Xrm.Page.getControl("statuscode").removeOption(100000005);
Xrm.Page.getControl("statuscode").removeOption(279640006);
Xrm.Page.getControl("statuscode").removeOption(279640011);
Xrm.Page.getControl("statuscode").removeOption(279640007);
Xrm.Page.getControl("statuscode").removeOption(100000017);
Xrm.Page.getControl("statuscode").removeOption(100000018);

}
}

</script>


Viewing all articles
Browse latest Browse all 79901

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>