How to check logged in user role in UI Policy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-08-2015 10:03 PM
Is there way to check logged in user role in UI Policy. Actually based on the logged in users role, I wanted to make fields read only/editable using UI Policy.
Is there any way by which we can make UI policy to execute before Client script.
- Labels:
-
Integrations
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-17-2015 09:34 PM
Hi Shane,
I have used script of UI Policy to get the role of logged in user.As per OOB functionality UI Policy executes after client script and I don't thing same can be changed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-16-2016 10:39 AM
I've used UI policies to govern fields based on role often enough. Sometimes, especially around Change management, ACLs are overly complicated and the process order from client script to UI policies may overwrite your client script from actually setting a field readonly/visible/etc.
For situations like this, I set the UI policy to Run Scripts and under Execute if true, run something like:
function onCondition() {
var hasRole = g_user.hasRoleExactly('role_name');
if (!hasRole) {
var fields = g_form.getEditableFields();
for (var x = 0; x < fields.length; x++) {
g_form.setReadOnly(fields[x], true);
}
}
}
Then the UI policy itself won't have any UI actions on it as the script will take care of your actions. I've used this method to ensure my UI policy script takes place after all the client scripts load (otherwise UI policies will undo whatever the CS does).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-18-2015 02:20 AM
Dear Pradeep,
The order of execution of the client scripts is defined by the system unlike UI Polices and we don't have control over it.
Your requirement can be achieved through ACL more easily.
Regards,
Probir