how to display values of one table from another table using client script

Pallavi16
Kilo Contributor

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

11 REPLIES 11

Ankur Bawiskar
Tera Patron
Tera Patron

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

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

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

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

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

Hi,

check this link on how to get and set multiple values using GlideAjax and onChange

https://community.servicenow.com/community?id=community_article&sys_id=53fa4b0adbd3cc1014d6fb2439961...

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader