GlideRecord GetDisplayValue in addquery

anfield
Tera Guru

I am importing some records to the cmdb, and running a onafter script to check if the manufacturer and model exists or doesnt exist and then creating those values (in those tables), then updating those values on the cmdb record.

What I want to ask is can I do a gliderecord query where the getdisplayvalue is part of the addquery? Not part of the query result, part of the query...Because I have two fields that I want to query at the same time in the product model table, manufacturer and the model (the manufacturer and model are supplied in a spreadsheet as part of an import through a transform map).

**Note - selecting "create" on the transform map wont work, because manufacturer and model need to be pushed to product model table so I am using this script.

Portion of the script: 

function productmodel_update(){

var grq = new GlideRecord('cmdb_ci_computer');
grq.addQuery('manufacturer', '=', source.u_manufacturer);

grq.addQuery('name','=', source.u_model)(;

grq.query();

 

Thanks

 

7 REPLIES 7

below line should work. try now. 

 

var grq = new GlideRecord('cmdb_ci_computer');
grq.addQuery('manufacturer.name',source.u_manufacturer);

grq.addQuery('name',source.u_model);

grq.query();

Thanks that helps. One more question though. When I try the opposite, not equal to, it doesnt seem to work, any idea why?

For example below, it doesnt find a match

grm.addQuery('department.name', '!=', department);

glad it helped. 

what is in department variable ? 

grm.addQuery('department.name', '!=', department); // add the log to check department  value