0

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!

  • 1
    Do you have any External Id fields on either parent? – Adrian Larson Jan 4 at 17:06
  • I do, but they're inconsequential to the test data that the 3rd party needs. All values will be null for the purposes of this Sandbox. – Sovereignty Jan 4 at 17:14
  • As far as I am aware of, there is no way you can insert a record with an existing Id, the only way its possible is by a sandbox refresh as you have already noted. – Jayant Das Jan 4 at 18:17
  • Thank you for your contribution Jayant, I appreciate you helping me out. Is there a faster way that you might know of to recreate junction object records without constant insertion, extraction, Vlookup and ID legend building? – Sovereignty Jan 4 at 18:19
  • I could only think of maintaining a separate object to just host the ids from production and newly inserted parent records. Then create the junction records after the insertion and populate the target ids from that object by looking up the values of production id. Think as a batch that runs after the parent records are insertion. This will be just taking away the work that is done in excel into a more apex oriented approach. – Jayant Das Jan 4 at 18:45
1

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.

  • Will look into this and mark as Answer if applicable, thank you David! – Sovereignty Jan 9 at 13:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.