- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2020 12:28 AM
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?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2020 12:37 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2020 12:37 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2021 03:21 AM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2020 12:41 AM
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.