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

Hi Harry,



Can you check this wiki link it mentions that if we use ignore=true in onStart then the entire transformation will be stopped and no further processing will occur.


http://wiki.servicenow.com/index.php?title=Transform_Map_Scripts#gsc.tab=0


Can you try adding some logs and check in error logs?



Regards


Ankur


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

I have had a read through that and one thing I have noted i this under onStart:



When: The onStart event script is processed at the start of an import run, before any data rows are read.



I think the problem here is that the data is not being read.



If i change it to onBefore and add error=true, it will import any rows that have all data populated and stop the transform when it comes across a row with missing data......so the code is ok and the data is being read when using onBefore.



May need to look at this a different way and delete any created records if an error occurs. Not sure how I would go about that though.



I cant see any events that will validate all of the data before starting the transform.


Hi Harry,



onStart transform script will not consider source.u_field1, rather you'll have to query (gliderecord) the import set table and apply the appropriate checks.



Hope this helps.



Best regards,


Harshit


Yes, Harry. You can right the code like this:

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

 

  {

 

  error = true;

 

  }

Source for this information is inside this link : https://www.servicenow.com/docs/bundle/xanadu-integrate-applications/page/script/server-scripting/re...

marcguy
ServiceNow Employee
ServiceNow Employee

yes it will need to be an OnBefore so each row is checked but set error to true.



error = true



and this will halt the entire transformation, unfortunately it won't delete or rollback any previously updated or created records...


Transform Map Scripts - ServiceNow Wiki


errorBoolean FlagWhen set to true, will halt the entire transformation for the current import set, with an error message.
error_messageString

Defines a custom message to be sent in the <error_message> XML response.



the only other option I can think of right now to give you an early heads up would be to put a check on the staging table so that the fields are checked there in your onStart transform