- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-06-2021 06:30 AM
Hi all,
We have a requirement to set Reference variable value similar to the value on the other reference field in catalog.
These two variables are from different variable sets, where they will refer to User(sys_user) table.
Request details is the first variable set.
Request for is the variable name - reference to User table.
Callback details is another Variable set.
Callback to is the variable name - reference to User table.
We need to set value of Request for == Callback to, when the request for value is Updated in the catalog request.
Please help me with the best approach, to achieve this.
Thank you,
Balaram.
Solved! Go to Solution.
- Labels:
-
Incident Management
-
Service Catalog

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-06-2021 06:41 AM
As long as they are both on the form, and both a reference field to the same table, you can simply create an onchange script for the Request for variable to set the value of the other:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
g_form.setValue('callback', newValue);
}
Just make sure you have the variable name correct for callback (you need the name, not the label).
Michael D. Jones
Proud member of the GlideFast Consulting Team!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-06-2021 06:41 AM
Hi,
You can write onChange client script on the variable "Request for"
Applies to Variable Set - Select your Request Details Variable set
Then select the variable name
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) {
return;
}
if(newValue == ''){
g_form.clearValue('callBackVariable'); // use valid variable name
}
g_form.setValue('callBackVariable',newValue); // use valid variable name
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-06-2021 10:43 PM
Did you mistakenly mark other answer as correct? As I see same script was provided before from my end pretty well (first).
You can mark only 1 response as correct.
So please mark appropriate response as correct and helpful.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2021 10:06 PM
Did you mistakenly mark other answer as correct? As I see same script was provided before from my end pretty well (first).
You can mark only 1 response as correct.
So please mark appropriate response as correct and helpful.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-06-2021 06:41 AM
As long as they are both on the form, and both a reference field to the same table, you can simply create an onchange script for the Request for variable to set the value of the other:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
g_form.setValue('callback', newValue);
}
Just make sure you have the variable name correct for callback (you need the name, not the label).
Michael D. Jones
Proud member of the GlideFast Consulting Team!