Hello
I'm trying to check if a user role is not in finance then disable all fields.
function ReadOnly() {
var UserRole = Xrm.Page.context.getUserRoles().toString().replace("{", "").replace("}", "");
var check = "f0d793f3-9e84-dd11-a5c4-001ec9d279c2"; //finance GUID
alert(UserRole +" "+ check);
if (UserRole != check) {
Xrm.Page.data.entity.attributes.forEach(function (attribute, index) {
var control = Xrm.Page.getControl(attribute.getName());
if (control) {
control.setDisabled(true)
}
});
}
}
I tried adding a few steps to make sure that the UserRole was formatted correctly for me to compare the two strings and ive also included a alert to I could make sure that the values were being passed through correctly. I set my user role to finance for testing but despite the variables matching it is still disabling all fields.
Can someone please help ?
Thanks