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

Prasad Pagar
Mega Sage

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

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

It is not displaying value

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

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?