Refreshing variable after Requested for change.

Nawal
Mega Guru

Hi, 

I have created a variable field (Lookup select box which retrieves groups Requested-for (Variable) belongs to : 

 

javascript: 'user=' + current.variables.requested_for_name + '^group.name!=' + ' approvers users' + '^group.active=true';

 

 

Nawal_0-1667200087085.png

 

now i m trying to refresh this field when the Requested_for changes on the form, i tried some scripts but still not working.

 

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
//check to see if the value has truly changed
if (oldValue != newValue) {

//clear the value of field below

g_form.clearValue('groups');

}

}

 

 

Nawal_1-1667200330222.png

 

 

Any idea please.??

 

Thank you so much

 

 

 

 

1 ACCEPTED SOLUTION

Pavankumar_1
Mega Patron

Hi @Nawal ,

isTemplate will not be available on catalog client script but which is in your script if you remove that it will work. refer my response

If your issue got resolved close the question by Accepting solution and hit thumb icon.

If it helps please click Accept as Solution/hit the Thumb Icon.
ServiceNow Community MVP 2024.
Thanks,
Pavankumar

View solution in original post

7 REPLIES 7

Sagar Pagar
Tera Patron

Hi,

Make sure variable names are correct!

 

Thanks,

Sagar Pagar

The world works with ServiceNow

Hi, 

I have checked that and names are corrects 😞

Hi @Nawal,

Your script will clear the selected values in group variables if selected requester and changed requesters are not same. it will not clear the applied filter.

 

Try this updated scritps -

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
//check to see if the value has truly changed
if (oldValue != newValue) {

//clear the value of field below

g_form.setValue("groups", "");

}

}

 

 

Thanks,

Sagar Pagar

The world works with ServiceNow

Still not working