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-08-2015 11:52 PM
Hello Pradeep,
You can use g_user.hasRole('role that you want') method to set fields as read only etc.
GlideUser (g user) - ServiceNow Wiki
there are many methods as well like hasRoleExactly(role) , hasRoleFromList(roles) .

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-08-2015 11:56 PM
Why do you need to execute ui policy before client script ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-09-2015 12:02 AM
Hi ,
Logged in users are saved in v_user_session table. Query the user data from the v_user_session table and get it's role by any role fetching syntax like " hasroles()" and set the fields to read only.
In UI policy you can set the order of the action to be taken set that to negative and it will be executed before the client script but it's not a good practice and you shouldn't apply client script and UI policy to a same field at the same time.
Thanks,
Jogendra Sharma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-17-2015 03:09 PM
Have you had any success with this Pradeep? I am looking to do something similar.
I want my global UI policy, to apply on a request form field, before a client script on the request has a chance to run.