Need to populate field based on certain condition in SOW which is there in backend in Incident form

ankitaankit
Tera Contributor

Hello Team,

Now I am having a Summary field on Incident form  which visible only when Priority is P1(written as part of UI Policy) and also  is having  ACL as :Allow write for Summary in Incident, for users with role major_incident_manager, and if the below ACL script returns true.
which is as below:
 
 if (current.incident_state == '7') {
    answer = false;
} else {
if(gs.getUser().isMemberOf(gs.getProperty('group.sys_id.WW-XX-MOM-TEST'))  ){
answer = true;
}
else{
answer = false;
}
    
}
 
My requirement is to show the same field "Summary" on SOW and all these conditions should work there too,
Though I added the field from  form Layout in particular view, and wrote a On Change Client script on Priority  under Service Operation Core scope to attain the same functionality 
but the field becomes visible on load , so my client script is not working.
 
Please help how can I attain it in SOW.
 
Thanks.
1 ACCEPTED SOLUTION

prerna_sh
Giga Sage

Hi @ankitaankit 

Check your UI Policy applies on global, check this global box Checked. 
Also add field in these views 'service operation workspace" and "service operation workspace new record". Please refer screen shot for your reference

ed478b3b-4d6c-47d5-b4a9-d03ddea449f9.png

Screenshot 2025-07-22 162607.png
If my response solves your query, please marked helpful by selecting Accept as Solution and Helpful. Let me know if anything else is required.
Thanks,
Prerna

View solution in original post

3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

@ankitaankit 

Please delete this duplicate question.

Your similar question is already having a comment.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

prerna_sh
Giga Sage

Hi @ankitaankit 

Check your UI Policy applies on global, check this global box Checked. 
Also add field in these views 'service operation workspace" and "service operation workspace new record". Please refer screen shot for your reference

ed478b3b-4d6c-47d5-b4a9-d03ddea449f9.png

Screenshot 2025-07-22 162607.png
If my response solves your query, please marked helpful by selecting Accept as Solution and Helpful. Let me know if anything else is required.
Thanks,
Prerna

Mounika30
Kilo Sage

You need to combine an onLoad Client Script with your existing onChange Client Script to ensure the field is hidden or shown correctly on form load.

1. onLoad Client Script

function onload(){
var priority = g_form.getValue('priority');
if (priority !== '1') {
g_form.setDisplay('summary', false);
} else {
g_form.setDisplay('summary', true);
}
}

 

2.onChange Client Script (on Priority field)

function onChange(control, oldValue, newValue, isLoading, isTemplate) {

if (gForm.getValue('priority') === '1') {
gForm.setDisplay('summary', true);
} else {
gForm.setDisplay('summary', false);
}

}

 

Make sure that below points are validated.

  • Add the field to the SOW form layout.
  • Add both onLoad and onChange Client Scripts.
  • Confirm the ACL applies to the requirement view.
  • Test with different users and priorities.