How to make the custom field “Change Template” read‑only only in the SOW view

Angel k
Tera Contributor

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?  

2 REPLIES 2

Vishal Jaswal
Tera Sage

Hello @Angel k 

Create UI Policy as shown below:

VishalJaswal_0-1778866944648.png

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:

VishalJaswal_1-1778867006917.png



Native UI:

VishalJaswal_2-1778867033135.png

 

 


Hope that helps!

Tanushree Maiti
Tera Patron

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

TanushreeMaiti_0-1778908043192.png

 

Result in SOW:

TanushreeMaiti_0-1778909360823.png

 

 

 

 

Please Accept the solution if it assisted you with your question & Mark this response as Helpful.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti