Want to make variables mandatory on incident form when assignment group changes

siva14
Tera Contributor

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

 

siva14_0-1702026627999.png

 

3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

@siva14 

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.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

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

}

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

}

 

Please hit like and mark my response as correct if that helps
Regards,
Musab