- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2023 09:12 AM
Hello,
On the incident form, I have the additional comments set to mandatory when the state is on hold (through UI policy). The problem is that the comments field stays mandatory while on hold, even when I just want to update the category field for example.
So I was thinking to use a change operator in the UI Policy so comments are only mandatory when the state changes to on hold, and not while it is on hold. The thing is, there is no change operator in UI policy.
I've found a similar thread that advises using an onChange client script instead of UI policy.
However, I'm new to all of this and have no idea how to code it. Anyone able to help? Thanks in advance.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2023 09:33 AM
Hi @JordyZ
Please try below Client Script:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if(newValue=='3') {
g_form.setMandatory('comments',true);
} else {
g_form.setMandatory('comments',false);
}
}
Thanks
Anubhav Ritolia
ServiceNow Rising Star 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2023 09:33 AM
Hi @JordyZ
Please try below Client Script:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if(newValue=='3') {
g_form.setMandatory('comments',true);
} else {
g_form.setMandatory('comments',false);
}
}
Thanks
Anubhav Ritolia
ServiceNow Rising Star 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2023 09:55 AM
This did the job, thank you!
If you have the time, I have another problem, it's regarding SLA notification and how to get time zone of the caller. Someone has given a solution but it's not working for me, unfortunately. If you could take a look, would be much appreciated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2023 09:37 AM - edited 01-16-2023 09:39 AM
You can write an onChnage client script on State field.
if (g_form.getValue('state') == '3') {
g_form.setMandatory('comments', true);
}
Please mark Helpful/Correct, if helped.
Thanks!