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

Pavankumar_1
Mega Patron

Hi @Nawal ,

isTemplate method will not available on onchnage catalog  client script but in your script I saw that method.

May be that is the it is not working.

So use same script which I provided below

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue === '') {
        return;
    }
    if (oldValue != newValue) {
        g_form.setValue('groups', '');
    }
}
If it helps please click Accept as Solution/hit the Thumb Icon.
ServiceNow Community MVP 2024.
Thanks,
Pavankumar

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

Pavankumar_1
Mega Patron

HI @Nawal ,

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