How to set field as read only based on role
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2024 05:33 AM
Hi Everyone,
I have to set field as read only based on role of logged in user. But the script in UI policy is not coming. The check field of script is not clicking
Can someone suggest. How can I enable it.
Thanks in advance

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2024 05:39 AM
Hello,
You can Create ACL instead of UI policy.
https://www.servicenow.com/community/developer-forum/making-a-field-read-only-for-user-with-role-usi...
https://www.servicenow.com/community/developer-forum/ui-policy-script-readonly-fields/m-p/2067739
If my answer is helpful pls mark it as correct and helpful
Br,
Pratiksha.k
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2024 06:22 AM
Hi @Abhijit Das7 ,
There are some limitations for UI Policies for specific scopes. I believe, scope that you are using is preventing you from running the script. Try creating UI Policy in some other scope, it might work. Still you can deactive the rule which is restricting. But I would strongly recommend not to touch OOB.
For checking user role in UI policy you can use below syntax
g_user.hasRole('role_name')
Regards,
Dhanraj.