Ui policy to not run when user has specific role

Khalnayak
Tera Guru

hi guys,

I have a UI policy which makes the PIR fields in a change form read-only.

However I don't want this UI policy to run if the user has role  change_manager.

How can I put this in the UI policy script to take affect please?

1 ACCEPTED SOLUTION

Michael Jones -
Giga Sage

You could also modify your UI Policy and, instead of using an action to set the fields read only, use the run scripts option and in your script for true, use something like this. 

function onCondition() {

if(!g_user.hasRoleExactly('change_manager')) {
	g_form.setReadOnly('<name_of_field>', true);
}

}

That would get the job done as well. 

I hope this helps!

If this was helpful or correct, please be kind and remember to click appropriately!

Michael Jones - Proud member of the CloudPires team!

I hope this helps!
Michael D. Jones
Proud member of the GlideFast Consulting Team!

View solution in original post

9 REPLIES 9

This does not defeat the idea of using an ACL to protect the field. Create a write ACL for that field and configure it to allow editing it if the change has not been closed OR if the user is a change manager.

Michael Jones -
Giga Sage

You could also modify your UI Policy and, instead of using an action to set the fields read only, use the run scripts option and in your script for true, use something like this. 

function onCondition() {

if(!g_user.hasRoleExactly('change_manager')) {
	g_form.setReadOnly('<name_of_field>', true);
}

}

That would get the job done as well. 

I hope this helps!

If this was helpful or correct, please be kind and remember to click appropriately!

Michael Jones - Proud member of the CloudPires team!

I hope this helps!
Michael D. Jones
Proud member of the GlideFast Consulting Team!

Thanks Michael, I had a similar scenario and adding this script to my UI policy is now allowing the change manager to edit the relevant fields that are read-only to all other users (however I take note of your comment that the requester would still be able to update these fields in the list view, which is why creating a 'write' ACL may be better).

Khalnayak
Tera Guru

Please can you just tell me how do it via UI policy

See above answer, sorry. Just keep in mind, UI policy only stops users from editing those fields on the form view. They would still be able to edit them from the list view. May or may not be a concern for you. 

I hope this helps!
Michael D. Jones
Proud member of the GlideFast Consulting Team!