- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2022 12:14 AM
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';
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');
}
}
Any idea please.??
Thank you so much
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2022 05:42 AM
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.
ServiceNow Community MVP 2024.
Thanks,
Pavankumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2022 12:24 AM
Hi,
Make sure variable names are correct!
Thanks,
Sagar Pagar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2022 12:30 AM
Hi,
I have checked that and names are corrects 😞
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2022 02:20 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2022 05:59 AM
Still not working