function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
kathyanikathyani 

Import look up data from one environment (sandbox) to another environment (staging)

When importing large amounts of data from one environment to another and if that data has look up data as its field value then this would not work because of the record id mismatch. The new environment would have a record id generated that is different from the record id of old environment.

I did the below steps and it worked but is this the correct way to do it. Please let me know.



 In Sandbox:

I created a table called Parent.
I created a table called Child that has Parent as its look up table.
I exported data using reports from Sandbox for tables: Parent and Child and saved it on my desktop. So this is the data which needs to go into production. 


In Production:

I created a custom field External ID fields for Parent table. When creating this field I checked the check box External ID (which is unique  /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:"Times New Roman";} @page Section1 {size:8.5in 11.0in; margin:1.0in 1.25in 1.0in 1.25in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} --> (belbelow the unique and required check boxes).

I imported data into Parent by mapping the External_ID__c of this table to the Parent: ID from csv file (Parent: ID from Sandbox).


Now in production I have

External_ID__c of Parent (Production) = ID of Parent (Sandbox)


To import child records, logged into data loader

1. Select 'upsert'
2. Select Child table
3. Click 'Next' on Select the field for matching on Child__c
4. Select External_Id__c for the parent
5. Click 'Create or Edit a Map' and map the fields (
6. Perform upsert.
 


 


David VPDavid VP
Yup,

That's a good way to do it (I've used this trick before too).

If it's just a one time migration, you can remove the external Id field in the destination org, if not just leave it there for future updates.


-David