GlideRecord GetDisplayValue in addquery
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-14-2020 08:38 AM
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
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-14-2020 10:22 AM
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();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-14-2020 01:00 PM
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);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-17-2020 09:05 AM
glad it helped.
what is in department variable ?
grm.addQuery('department.name', '!=', department); // add the log to check department value