Transform Map - Ignore Row if any fields are empty

Harry Campbell2
Mega Guru

Hello All,

When transforming an import set table. Is it possible to ignore any rows that have an empty field?

We want to ensure that all rows to be imported have complete information. Is there a transform script I can utilize to achieve this?

I have tried just using 'Enforce Mandatory Fields' but this doesn't work, the data is still imported with empty fields.

Many Thanks

Harry

15 REPLIES 15

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Harry,



Have this script in the onBefore transform script



if(source.u_field1 == '' && source.u_field2 == '' && source.u_field3 == '')


  {


  ignore = true;


  }



you will have to repeat the AND condition for all the fields you wanted to check with



Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.


Thanks


Ankur


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

shouldn't it be || instead of && (if ANY field is empty, rather than if ALL the fields are empty?)



if(source.u_field1 == '' || source.u_field2 == '' || source.u_field3 == '')


  {


  ignore = true;


  }


Ankur Bawiskar
Tera Patron
Tera Patron

Hi Harry,



There should be an OR condition instead of AND since you want if any field is empty it should ignore.



Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.


Thanks


Ankur


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

Thank you for this, using the OR condition worked a treat. However after testing, the requirement has changed.



We would like it to ignore the whole import rather than just the individual rows, is this possible?