In a Transform, does the onAfter script execute if 'ignore' is set to true in the transform script?

Not applicable

In a transform script, the 'ignore' variable is being set to true.
However, the 'onAfter' script (or event handler) is still executing.

This is unexpected according to the documentation where it says about 'ignore':

where if true causes the current import row to stop processing.

link to documentation

Is it expected that the 'onAfter' script get called if the transform script sets 'ignore' to true?

6 REPLIES 6

john_andersen
Tera Guru

As Oleksiy Kosenkov mentioned, onAfter scripts will run even if the row is ignored.



I liked Dominik Simunek's suggestion to add a variable.   That did work for me.   That being said, I was able to check for this without adding a variable.



if you just do the following test in your onAfter script, you should be able to skip the script on ignore:




  //If this row was ignored, we should ignore it onAfter as we don't need to process this


  if( source.sys_import_state == "ignored"){


            return;


  }


Vincent Schmie1
Tera Contributor

Just stumbled upon the same issue and my solution to it looks like this.

 

(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
	if(!target.isValidRecord()) return;
	// your code
})(source, map, log, target);

So if some step in before or in the transformation made your record not elligable for insert, it will not be inserted at this point yet, so it will also not be a valid record.