Auto populate one variable on a Catalog item based on the value of another variable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-02-2020 02:31 AM
Hi!
On my test catalog item, I have created two variables, one call 'Location' and the other called 'Sitecode'. The 'Sitecode' value should automatically update when I select a value in the 'Location' variable.
I have created a custom table.
This is my test form.
This are my catalog item variables.
This is my client script.
Unfortunately, it's not working. What am I doing wrong? Can someone help me please?
BR
Manfred
- Labels:
-
Service Portal Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-02-2020 05:27 AM
Hi,
its a single line text variable type.
BR
Manfred
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-02-2020 06:50 AM
Hi,
what is the type of field Location? Is it a reference to your custom table? if yes then only the getReference() code would work
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
04-06-2020 01:02 AM
Hi.
This solution work for me
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var location = g_form.getReference('location_it', getLocationDetails);
}
function getLocationDetails(loc) {
if (loc) {
g_form.setValue('site_code2_it', loc.u_og_sitecode);
}
}
BR
Manfred