
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2016 08:16 AM
Hi,
I need to make the Close notes field mandatory when a problem state changes to Closed/Resolved. I'm using this client script, but it doesn't seem to be working.
Here's my code
function onChange(control, oldValue, newValue) { |
if (oldValue == newValue)
return;
g_form.setMandatory('short_description', true);
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2016 08:19 AM
You can do it using a UI policy without any code. Here is your client script code
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if(newValue==4){
g_form.setMandatory('field name goes here',true);
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2016 08:18 AM
When it comes to making things mandatory, visible, or read-only based on another field value... I strongly recommend a UI policy. No scripting
This appears to be one of those cases.
http://wiki.servicenow.com/index.php?title=Creating_a_UI_Policy

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2016 08:19 AM
You can do it using a UI policy without any code. Here is your client script code
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if(newValue==4){
g_form.setMandatory('field name goes here',true);
}
}