Entire transform map ignore if particular field is nil

prasanthraj
Kilo Contributor

Hi Experts, 

I have requirement entire import set need to ignore if particular field is nil. 

Eg - Excel sheet have 10 rows. At row 9th field x==nil then entire transaction need to ignore/skip/kill

How to achieve this scenario?

I have search other community result but not able find exact result.

 

1 ACCEPTED SOLUTION

Ah ok, onStart might be a better call as the script will halt the entire transform map, rather than running the same script on every row. I didn't realize setting ignore to true in an onStart script did that.

If I'm not mistaken I think he does want it to be a specific field that's null rather than any field, but it should halt if null in any row. I did forget to query for the specific import set in my previous example. However you should use import_set.sys_id, not map.sys_id. So here's the edited solution:

(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {

var gr = new GlideRecord('u_data_source');

gr.addQuery('sys_import_set', import_set.sys_id);
gr.addNullQuery('field_x');
gr.query();
if(gr.next()) {
   ignore = true;
}

})(source, map, log, target);

Run this onStart, and it should work.

View solution in original post

10 REPLIES 10

thanks, Chris Sanford

Finally, the requirement has completed. 🙂