We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

On change client script not to run once template applied

FareedaS
Tera Contributor

Hi,

I created on change client script to populate assignment group when subcategory changes in interaction table.but when i applied template then also on change client script overriding.

if (isTemplate) {
return;
} else {
code;
}

Please guide here to not to run when template is applied and when subacategory manually changes then on change client script runs.

1 REPLY 1

J Siva
Kilo Patron

Hi @FareedaS 
Try below script.
The assignment group value remains unchanged when the subcategory value is preset by the template.

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }
    if (!isTemplate) {
        g_form.setValue('assignment_group', '<GROUP SYS ID>');
    }
}

JSiva_0-1745044725642.png

Regards,
Siva