- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2022 11:46 PM
Not super familiar with transform map scripts - hoping someone can shed some light on a question I have.
We're importing users from AD, and when a new location is found on the user record it gets created in the location reference field (via the "Choice Action: Create" option).
Now if I wanted to add more values to this location record (cmn_location), which is data that can also be found in my import, where would be the best place to do that?
Should I write a business rule that is triggered when cmn_location records are created? The positive would be that it would only trigger once for each new location. The negative is that it's a business rule and the next admin to come along would have trouble understanding where the update is happening since it's not specifically part of the import/transform.
Or should I write an onBefore transform script? This would be part of the transform, easy to understand. But it would run for every user checking to see if the user's location was missing information. We have a lot of users so this doesn't seem very efficient.
Ideally I'd like this script to only run when new locations are created as a result of the "Choice Action: Create" option. Is that possible?
I noticed the OnChoiceCreate transform script type, however it seems to only apply for choices, whereas this is a reference.
Any guidance would be appreciated! Thanks
Solved! Go to Solution.
- Labels:
-
Instance Configuration
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2022 12:03 AM
You can write OnForeignInsert Transform script.
The onForeignInsert event script is processed at the start of the creation of a related, referenced record, before the record is created.
onForeignInsert will be called if there is a related record to insert.
Hope that helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2022 12:03 AM
You can write OnForeignInsert Transform script.
The onForeignInsert event script is processed at the start of the creation of a related, referenced record, before the record is created.
onForeignInsert will be called if there is a related record to insert.
Hope that helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2022 12:10 AM
Hi,
you can use onForeign insert transform script as mentioned.
OR
You can use onBefore transform script and remove the field map for that Location field
a) in onBefore check if the location exists; if yes then map
b) if not then create location with the fields from import set; attach the new location in the target reference field
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
05-31-2022 12:27 AM
Hi,
in this scenario i would prefer before script.
for more information kindly refer the link below.
https://docs.servicenow.com/en-US/bundle/sandiego-platform-administration/page/administer/import-sets/task/t_AddOnBeforeScriptToTransformMap.html