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

alchn
Kilo Explorer

Having the same behavior in our test. Would like to know this as well.


Dominik Simunek
Tera Guru

I had the same issue and I resolved it by creating custom variable in onBefore transform script (or in Script of Transform Map record) and I set it to true if onAfter script should be ignored, otherwise to false. Then in onAfter script I checked this variable and it was available there. This was tested on Fuji release.



On Before transform script:


if (/* validation code indicates invalid values */) {


    ignore = true;


    var wasIgnored = true;


} else {


    var wasIgnored = false;


}



On After transform script:


if (wasIgnored == false) {


      // run my on after code


}


k0a1a
Kilo Expert

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



Looks like: Transform Map Scripts - ServiceNow Wiki


"If you have defined an onAfter script, the onAfter script runs for the current row even if the ignore flag is set to true."


Can ignore be set to true in an onAfter script or is the target record already saved?