how to display values of one table from another table using client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2022 05:43 AM
i have a request where i have one field called "requested By" from "sys_user" table which is of reference type variable in catalog form.
i have other variables where it should display the values from "computer table" based on name from above table.
Can anyone help me on this
- Labels:
-
Team Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2022 05:48 AM
Hi,
in the 2nd variable you can use advanced reference qualifier
Example: if your computer variable refers to cmdb_ci_computer table
something like this
javascript: 'assigned_to=' + current.variables.requested_by;
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
02-14-2022 05:59 AM
if the computer variable is reference type and if requested by user has multiple computers associated; you can populate only 1
if that variable is of type list collector then you can use GlideAjax and set all the computers to it
Check my blog on how to set value in list collector based on change of another variable. It works in both native + portal.
Dynamically set list collector on change of variable
if my blog helps please mark it helpful and also bookmark it
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
02-14-2022 06:06 AM
Computer variable is not reference type.
There are 3 variable from computer table serial number, model and name. These 3 should auto-populate based on requested by from sys_user table.
var attrRecord = new GlideRecord("cmdb_ci_computer");
attrRecord.addQuery('assigned_to',newValue);
attrRecord.query();
if (attrRecord.hasNext())
g_form.setValue('service_tag_serial_number','serial_number');
I ahve tried above code but it is not displaying value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2022 06:12 AM
Hi,
check this link on how to get and set multiple values using GlideAjax and onChange
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader