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

Client script to check condition assignment group

Shiva Kumar8
Kilo Guru

Hi Community,

I'm writing a client script to check whether the assignment group starts with 'IT' or not I tried many proposed solutions in the script but it is not working can anyone please suggest the correct way to check the condition.

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron

Hi Shiva,

you can write onChange client script on assignment group field

Sample script below

Use proper field name for assignment_group

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading) {
        return;
    }

var groupName = g_form.getDisplayBox('assignment_group').value;

groupName = groupName.toString();

if(groupName.startsWith('IT')){

alert('starts with IT');

}

else{

alert('doesn't start with IT');

}

}

Regards
Ankur

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

View solution in original post

2 REPLIES 2

Ankur Bawiskar
Tera Patron

Hi Shiva,

you can write onChange client script on assignment group field

Sample script below

Use proper field name for assignment_group

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading) {
        return;
    }

var groupName = g_form.getDisplayBox('assignment_group').value;

groupName = groupName.toString();

if(groupName.startsWith('IT')){

alert('starts with IT');

}

else{

alert('doesn't start with IT');

}

}

Regards
Ankur

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

Dhananjay Pawar
Kilo Sage

Hi,

Try below onChange client script.

 

function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) {
return;
}

var groupVal= g_form.getReference('assignment_group').name;

if(groupVal.startsWith('IT')){

alert('Group name starts with IT');

}

else{

alert('Group name doesn't start with IT');

}

}

Thanks,

Dhananjay.