How to make the custom field “Change Template” read‑only only in the SOW view
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
I am working on an SOW story and need guidance on configuring the Change Template field. My requirement is to make this field read‑only in the SOW view, while ensuring that it remains editable in the default Change form.
Could someone suggest the best approach to achieve this without impacting the default Change form behavior?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
Hello @Angel k
Create UI Policy as shown below:
Execute if true:
function onCondition() {
alert(g_form.getViewName()); //comment this
if (g_form.getViewName() == 'sow') {
g_form.setReadOnly('u_change_template', true);
}
}
Execute if false:
function onCondition() {
if (g_form.getViewName() == 'workspace') {
g_form.setReadOnly('u_change_template', false);
}
}
Validation Results:
Service Operations Workspace:
Native UI:
Hope that helps!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
Hi @Angel k
Using UI policy without any scripting , you can achieve it.
- Navigate to System UI > UI Policies in the main ServiceNow instance.
- Click New to create a new UI policy.
- Right-click the form header and select View > Default View (or the view used in the standard change form) to verify you are working in the right place.
- Uncheck the Global checkbox.
- In the View field that appears, select the SOW view
- Set the Table to change_request
- Right-click the header and Save.
- Scroll to the UI Policy Actions related list at the bottom of the form and click New.
- Select your custom Change Template field.
- Set the Read only field to True.
- Click Submit
Result in SOW:
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti