Record exists using GlideRecord

maryc
Tera Contributor

Hi,

I am connecting to external app using REST and am parsing the response. Before inserting into CMDB, I want to check if the record exists and am trying to use this query.

var isinsert=false;
var commrecord = new commrecord("cmdb_ci_comm");
commrecord.addQuery("asset_tag",parsed_object.AssetNumber);
commrecord.query();
//gs.log(" isinsert "+isinsert);
if(commrecord.next()){
    isinsert=false;
}else{
    isinsert=true;
    commrecord.initialize();
}

If I execute this script as background script hard coding the asset number, it works perfectly. While parsing the REST response, it always says its a new record and inserts duplicate records.

Any help here is appreciated,

 

 

5 REPLIES 5

Hi,

which value from json you want to parse and you want to query that against which field of table?

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

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