Transform Map Ignore on Before Script, does this skip After Script too?

tahnalos
Kilo Sage

We have a Transform map that has a Before script and an After Script.

The Before Script uses a script include to check if certain conditions in the source record are true.  If they are not, then the ignore flag is set to true.

We have an After script that is supposed to do some very heavy lifting.  But we noticed that the After Script is running on rows in which the Before Script would have set the ignore flag.

I was under the impression that the ignore flag means that the record is not imported and the scripts that occur on import are not executed, but it would appear that it doesn't do so.  Worse, using the same conditions from the Before Script to trigger an ignore won't work in the after, due to field level changes essentially changing the record, and not qualifying it to be ignored (or worse, triggering legit records to be ignored).

Is there any other way for an after script to not run during an ignore established from a before script?

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

yes it is a known issue

The onAfter script does not have access to the ignore object value from the onBefore script.

workaround is mentioned here

if (source.getValue("sys_import_state") === ‘ignored')
return;

Refer this -> Import Set onAfter script runs for ignored rows during transformation

Regards
Ankur

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

View solution in original post

3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

yes it is a known issue

The onAfter script does not have access to the ignore object value from the onBefore script.

workaround is mentioned here

if (source.getValue("sys_import_state") === ‘ignored')
return;

Refer this -> Import Set onAfter script runs for ignored rows during transformation

Regards
Ankur

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

 

In my case, can we make the OnAfter script to not execute if OnReject script is triggered by Choice Action field in Fields map of Transform Map.

if (source.getValue("sys_import_state") === ‘rejected')
return;

I am believing this is sequence for the transform execution:

On Before, transform map, on reject and then On After.  Please confirm

asifnoor
Kilo Patron

After script runs when the row is transformed.

If the row is ignored during onBefore script, then the target record will not be updated.

In the after script check the value of action and add your conditions accordingly.