Transform Map Script - Insert Only Active Records

Dhruv Chandan
Giga Guru

Help Needed..:)

In the transform map I've marked "Run-script" as true and then writing the script over there.

I'm referencing the location table (cmn_location). My target field name which is a reference field t location table is "u_location". In the location table full name (full_name) is unique.

Question: When i do the data load, the location for which Active (u_active) is FALSE should get ignored ( active is a check-box field).

Following is the script

var gr = new GlideRecord(cmn_location);

gr.addQuery('full_name',source.u_location);                   // source name in T-Map is "u_location"

gr.addQuery('u_active',false);                                                                   //query location table if the record is false

gr.query();

while (gr.next())

{error_message='';

ignore=true;   // here it should ignore the record which is Active = false, but this script is not working

}

any help is appreciated.

1 ACCEPTED SOLUTION

Thank for the help Arpit,



i figured out the problem which was that both of us forgot to put single quotes in the glide record. It should be like



var gr = new GlideRecord('cmn_location'); //single quotes and the function is runnig


gr.addQuery('full_name',source.u_location);


gr.addQuery('u_active',false);


gr.query();


while (gr.next())


{error_message='';


ignore=true;


}



appreciate you help buddy


View solution in original post

3 REPLIES 3

arpitt
Tera Expert

Try this:



var gr = new GlideRecord(cmn_location);


gr.addQuery('full_name',source.u_location);                   // source name in T-Map is "u_location"


gr.addQuery('u_active',false);                                                                   //query location table if the record is false


gr.query();


while (gr.next())


{


error = true;


error_message='';


//ignore=true;   // here it should ignore the record which is Active = false, but this script is not working


}


Thank for the help Arpit,



i figured out the problem which was that both of us forgot to put single quotes in the glide record. It should be like



var gr = new GlideRecord('cmn_location'); //single quotes and the function is runnig


gr.addQuery('full_name',source.u_location);


gr.addQuery('u_active',false);


gr.query();


while (gr.next())


{error_message='';


ignore=true;


}



appreciate you help buddy


Ashish Kumar Ag
Kilo Guru

Try the below code in script part.



if(target.u_active == false);


ignore = true;