Want to make variables mandatory on incident form when assignment group changes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-08-2023 01:14 AM
we want to make variables fields mandatory on incident form when assignment group changes to another group, i want to make Rejected and rejected comments fields, and also please help me how to capture those values in activity
PFB screenshot,
i tried UI policy , but didn't find an option to select variable field name in UI action
#incident # variables #activity
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-08-2023 01:36 AM
you should use normal onChange client script on incident table and group field.
then make the variables mandatory using this syntax
g_form.setMandatory('variables.variableName', true);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-08-2023 03:38 AM - edited ‎12-08-2023 08:51 AM
Hi @Ankur Bawiskar ,
i have tried this code already, but it's not working as expected.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var assinGrp = g_form.getDisplayBox('assignment_group').value;
alert(assignment_group);
if(newValue !== oldValue)
g_form.setMandatory('variables.rejected',true);
g_form.setMandatory('variables.rejected_comments',true);
//Type appropriate comment here, and begin script below
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-12-2023 02:10 AM - edited ‎12-12-2023 02:11 AM
Try this.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var assinGrp = g_form.getDisplayBox('assignment_group').value;
alert(assignment_group);
if(newValue != oldValue)
{
g_form.setMandatory('variables.rejected',true);
g_form.setMandatory('variables.rejected_comments',true);
}
else
{
g_form.setMandatory('variables.rejected',false);
g_form.setMandatory('variables.rejected_comments',false);
}
//Type appropriate comment here, and begin script below
}
Regards,
Musab