[SalesForce] way to insert data with specific IDs

I'm not sure if I'm explaining this correctly but I'll give it a shot.

I'm trying to use Data Loader to insert CSVs of data into a Partial Pro sandbox, but I want these inserted records to use the same id18s as my Production Org, similar to what happens when a Full sandbox is refreshed.

The purpose of this is to provide a 3rd party with as near to a Production Org environment as possible, with access to the Full sandbox not being an option.

Why this is necessary is because several junction objects exist that I will need to use parent-insert/child-insert/junction-insert/rinserepeat insert operations in order to provide them with some useful test data. My concern is that I don't know of a way to easily insert junction object relationships without – after each insert step above – doing an extraction of the IDs created during the insert, doing an extensive VLOOKUP to match them with their former IDs from Production, and constructing a legend that will then need to be used to replicate the junction object records.

Is there a better way to do this? Hopefully this was clear? Available for questions and thanks in advance!

Best Answer

You need to use the upsert function of Salesforce data loader and treat the original IDs as custom external iDs in the sandbox. That way you don't need to use VLOOKUP.

For each object in the sandbox, create an "Old ID" field and set it as External ID. Import your parent records using normal insert and map the original ID column to the Old ID field.

Then use upsert to import your child records. This article has some good basic information: https://www.jitendrazaa.com/blog/salesforce/all-about-upsert-and-external-id-in-dataloader-and-apex-videos/

In the Step 2a screen, I would choose the standard ID field, not the Old ID field.

In the field mappings screen, you can then map the parent ID columns to the related parent Old ID fields. I would also blank the child's standard ID field mapping and map the original child ID to the Old ID field.

Related Topic