- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2022 06:32 AM
How do I know that whether record is inserted or updated using transform map script
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2022 09:04 AM
So if you use an onBefore script there is an "action" variable that will tell you if its going to update or insert a new record.
https://docs.servicenow.com/bundle/sandiego-platform-administration/page/script/server-scripting/reference/r_MapWithTransformationEventScripts.html
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2022 09:56 AM
then syntax will be if(action=='insert)..am I right??

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2022 09:32 AM
Hi,
As you mentioned, you have access to "action" which will tell you if it classifies as an insert or update.
Is there anything specific you wanted to discuss regarding that or did you just want to confirm it?
You're on the right track! 🙂
Please mark reply as Helpful, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2022 10:10 AM
Hi,
You can use, example:
if (action == "insert") {
//do x
}
Further example here and this can even be done in onBefore: https://docs.servicenow.com/en-US/bundle/sandiego-platform-administration/page/administer/import-set...
Please mark reply as Helpful, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2023 12:53 AM
For anyone wondering, in the "onAfter" Transform Script, you can find out by the following code:
if(source.sys_import_state == 'inserted'){
// do magic
}
After the record gets processed, the transform map engine goes back and updates the import set row record. At which point you can access it via the "source" object.