Transform maps in ServiceNow let you load data from a staging table to a target table. I recently worked on an integration where a third-party tool was inserting records on staging table & we wrote a Transform map to load this records into target table from the staging table. During this work, I came accross many instances, where I was fooled with how things work in the background! Let me share few such moments.
- onAfter scripts run at the end of each row transformation I thought an onAfter script runs at the end of transform map. But they are executed at the end of each row transformation. When a row transform completes, the script executes.
- onAfter scripts run, no matter what happened to the row transformation onAfter scripts would run, even if the row transform was failed/ignored. This was mindblowing for me. I wrote an onAfter script to update the record, when the transformation is completed for every row. I expected it to work only if the transformation is successful!!. But, an onAfter script executes, even if the row transformation is failed! Be careful to put a check in script to execute only if the row transform was successful
- Run Business Rule I expected a certain CIs to be created when an asset record is inserted during the transform process. But asset creation was happening, but a CI was not created. When I tried viewing the asset record, my browser was stuck. Later did I release, this happens if there's no CI mapped to asset. It took me a day to realise that "Run Business Rules" was unchecked in the transform map! If there's some dependency of some script execution after the record insertion, make sure this is checked.
As of now, these are few of the moments, which made me feel more dumb about myself. Let me keep this updated, anytime I see myself making fool with the transform maps!