Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Insert for Transform map

Priya123
Tera Contributor

hi all

i have a transform map where i have a coalesce field.

I want to only update records if coalesce is true 

No insert if  no match

 

provided the below script on the Run Script on the transform but its still inserting. 

 

(function transformRow(source, target, map, log, isUpdate) {

   if (action == 'insert' ){
        ignore = true;
        }
})(source, target, map, log, action==="update");
11 REPLIES 11

harshav
Tera Guru

Write an onBefore transform script

 

var gr = new GlideRecord('your_table_name'); // this one is your target table
gr.addQuery('number', 'xxxxx'); // here your coalese field name
gr.query();
if(!gr.next()){
    ignore = true;
}

 

Priya123
Tera Contributor

Still inserting. tried this too

Can you please share your code

 

var gr = new GlideRecord('your_table_name'); // this one is your target table
gr.addQuery('number', source.u_number); // here your coalese field name
gr.query();
if(!gr.next()){
    ignore = true;
}

In line 2 are you bringing your importset field name. Also make sure is there any other script on After or on before with different condition

Sandeep Rajput
Tera Patron
Tera Patron

 @Priya123 You should configure onBefore Transform script as follows.

 

app_store_learnv2_importingdata_utah_importingdata_images_import_noinsertsscript.png

Source: https://developer.servicenow.com/dev.do#!/learn/courses/utah/app_store_learnv2_importingdata_utah_im...