Why Import set is only updating not inserting new records

Prathamesh Cha1
Tera Contributor

error message

PrathameshCha1_0-1722935087048.png

 

script to fetch RAM sys_id

 
(function transformRow(source, target, map, log, isUpdate) {
    var up = new GlideRecord('sn_risk_advanced_risk_assessment_methodology');
    up.addEncodedQuery("name=" + source.u_expected_ram + "^state=2");
    up.query();
    if (up.next()) {
        target.risk_assessment_methodology = up.sys_id;
    } else {
        ignore = true;
    }
 
PrathameshCha1_1-1722935203701.png

excel sheet

 

PrathameshCha1_2-1722935244049.png

if entity and current ram combination found simply update he record

if not insert new one

RAM is the field on target table which should get updates with expected RAM column from excel sheet


})(source, target, map, log, action === "update");

 
 
this is working fine for updates
2 REPLIES 2

Hemanth M1
Giga Sage
Giga Sage

Hi @Prathamesh Cha1 ,

 

Can you comment ignore =true; and try 

When your query wouldn't find existing record it goes to the else part and skipping everything.

  var up = new GlideRecord('sn_risk_advanced_risk_assessment_methodology');
    up.addEncodedQuery("name=" + source.u_expected_ram + "^state=2");
    up.query();
    if (up.next()) {
        target.risk_assessment_methodology = up.sys_id;
    } else {
        //ignore = true;
    }

 

 

 

Accept and hit Helpful if it helps.

Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025

Hi @Hemanth M1 ,

Thanks for reply And I tried with solution you provided but still it is skipping the records, as records do exits with that encoded query.