- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2023 04:33 AM - edited 01-12-2023 04:41 AM
Morning!
I am trying to make additonal comments required when an incident is cancelled, however i am experiancing some strange behaviour.
Client script OnChange
UI type = ALL
Field = State
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
// var state = g_form.getValue('state');
if (newValue == 8 ) {
g_form.setMandatory('comments', true);
g_form.showFieldMsg('comments',"Additional comments are required when cancelling an incident.");
}
}
When this runs it pops up the additonal comments field, however it is not required.
Example of odd behaviour:
If it is in a new state, and i change to cancelled, nothting happens. If it is in a new state, i change to work in progress then change to cancelled (all before saving) then the field does become required.
Any assistance would be greatly appriciated.
Thanks!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2023 05:06 AM
Search this UI policy on incident table and uncheck the reverse if false or add your state condition in that UI policy it self. This UI policy is conflicting your Client script logic.
Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2025 10:23 PM
where to add the above script?