Transform map for new records with parents
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-27-2019 06:21 AM
I have an import file of about 50,000 Incident records. On the Incident record is a parent field that refers to another incident.
I am reimporting these as CSM Cases and I need to update the parent field on the Case record to the new Case we created (not the original Incident). How do I go about accomplishing this?
If my import hits a child incident first, then it won't know enough to create the parent Case record from the spreadsheet to continue but I most certainly don't want to do two separate imports (one for parents, one for children).

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-27-2019 08:15 AM
Well, the most straight forward path would be to create two transform maps and make sure you have all parents first 🙂
That said, you could avoid that with some clever transform scripts.
The logic needs to happen on the reference field parent. You can create a couple of scripts here:
- onInsertAfter
Everytime a new parent record is inserted (which is an empty shell) you can gather the sys_id of that record and store it in a array/map along with the UID of got from your import column.
- onBefore
Use the parent information in the source to find the record in the database of in the array/map to make sure you link to the correct recorcd
- onBefore
Use the map to check if an empty shell records has already been created for this record, if yes change the sys_id of target to overwrite information
This should allow you to create parents and childs in one go. Bear in mind it will use more memory as it needs to hold that map. But 50k records should be fine.