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:50 AM
Hi Pallavi,
Did you tried writing something by your own?
Just a hint - you need to glide on computer table passing requested by as addQuery.
I will suggest, try writing script and in case you face any challenges we are here to help you 🙂
Happy Learning !!!
Thank you
Prasad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2022 05:59 AM
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');
new Value is requested by -name
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2022 06:01 AM
It is not displaying value

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2022 06:20 AM
Hi,
Considering requested by is reference field to sys_user table.
Try this
var attrRecord = new GlideRecord("cmdb_ci_computer");
attrRecord.addQuery('assigned_to',newValue);
attrRecord.query();
if (attrRecord.next())
{
g_form.setValue('service_tag_serial_number',attrRecord.serial_number);
}
Hope this helps
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2022 06:30 AM
Hi
Still it is not displaying value.
I have written one more script.
var gr =g_form.getReference('requeste_by', doVal);
}
function doVal(gr)
{
g_form.setValue('service_tag_serial_number', gr.serial_number);
g_form.setValue('model_type',gr.model_id);
g_form.setValue('computer_name',gr.name);
}
here it dispalys all values but for second one it is displaying sys_id instead of value
First and third one are of string type
second one is reference type.
Could you please suggest me to get display value of second one?