- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2017 02:13 AM
Hi Team,
When a request is re-assigned to a different assignment group I need work_notes to be mandatory.
If I am re-assigning to a different user within the same group work_notes should not to be mandatory.
For that I have written client script onsubmit as follows, but it is not working as expected, please suggest is the syntax is correct or not.
Also please guide how to add logic "When I am re-assigning to a different user within the same group work_notes should not to be mandatory".
function onSubmit() {
//Type appropriate comment here, and begin script below
var x = g_form.getValue('assignment_group');
//.changed from Checking for Modified or Changed Fields in Script - ServiceNow Guru
if($$('.changed').length > 0 && x == ''){
g_form.setMandatory('work_notes', true);
g_form.addErrorMessage(getMessage("Work notes are mandatory when the 'Assignment group' field changes"));
} else {
return false;
}
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2017 02:23 AM
This is the script
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if(oldValue != newValue)
{
g_form.setMandatory('work_notes',true);
}
//Type appropriate comment here, and begin script below
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2017 02:23 AM
This is the script
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if(oldValue != newValue)
{
g_form.setMandatory('work_notes',true);
}
//Type appropriate comment here, and begin script below
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2017 03:57 AM
But how to add logic "When I am re-assigning to a different user within the same group work_notes should not to be mandatory".

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2017 04:00 AM
That wont be necesasary since the script is only checking for the assignment group change.
If there is a field change of assigned to. The worknotes will not be mandatory.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2017 04:02 AM
so shall i keep an another onchange script on assigned to also

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2017 04:05 AM
As i said. that will not be necessary
Just add my script and it will work