- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2023 02:43 AM
Hi Team ,
Am trying to make read only fields in incident for agent role users ,But I can't find any option for roles in UI policy
Please guide me
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2023 03:03 AM
This scenario is best handled with the help of ACLs instead of UI policy, but still if you want to make read only with script you can create a new client script "on load" on the incident table and try below mentioned script(Not tested):
if(g_user.hasRole("ROLE") ) {
var fields = g_form.getEditableFields();
for (var x = 0; x < fields.length; x++) {
g_form.setReadOnly(fields[x], true);
}
}
If my answer solved your issue, please mark my answer as ✅ Correct & 👍Helpful based on the Impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2023 05:13 AM
I have seen you marked my answer helpful!
Please Accept the solution if it has answered your query, it would be helpful for future readers too

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2023 05:27 AM
hi @String ,
To make a field read-only for a specific role in ServiceNow, you can use a combination of UI Policies and Access Control. Here are the steps to achieve this:
- Go to the form view of the Incident table.
- Click on the gear icon in the top-right corner and select "Configure > Form Layout".
- Drag and drop the field(s) you want to make read-only to the "Additional actions" section.
- Click on the field you want to make read-only and note the "Variable name" in the right-hand side pane.
- Go to "System Security > Access Control > Roles" and open the Agent role.
- Create a new record in the "Read" column for the Incident table.
- In the "Conditions" section, add the condition "Variable name" "is" "sys_read_only".
- Save the record.
- Go to "System Definition > UI Properties" and create a new UI Policy for the Incident table.
- Set the "UI Policy" condition to "true".
- Add an action to set the read-only field(s) to "true".
- In the "Advanced" section of the action, add the condition "Current > Role" "is" "agent".
- Save the UI Policy.
Now, when an Agent user views the Incident form, the specified field(s) will be read-only.
Thanks,
Rahul Kumar
Thanks,
Rahul Kumar