1. Link child record with the respective parent
record in Target org. using Talend.
While migrating the child records from one Salesforce org.(OrgA) to
another(OrgB) I was facing hard time to link the child record with the
respective parent record in target org.(OrgB). Because when you create new
record in Salesforce it will create it with the unique Id in target
Org.(OrgB).
I though this would be the common scenario while migrating data from one
Org. to another. So, I am going to provide you the step by step process to
link the child record with the respective parent record:
1. First thing you need to do is to create a custom field say
ExternalIdField on Account object in target org.(OrgB) and select the
External ID check box.
2. Follow the steps which I have provided in my previous post to make the
connection between source org. to target org.
3. We use tMap to create the mapping between the org.'s, double click on
it and link the id field of Account(OrgA) to the ExtenalIdField custom
field on target org.(OrgB).
4. Run the job, it will migrate account records from OrgA to OrgB.
5. Next time when you do the same for child records say Contact records;
first fetch the child records(tSalesforceInput) from OrgA and Parent
record (tSalesforceInput) from OrgB.(Select id, ExternalIdField__c from
Account).
6. Drag the tMap and tSalesforceOutput(OrgB) component into the designer
view.
7. Now double click on tMap componet, it will open the new window, on the
left hand side you must be seeing two table(Contact (OrgA) and
Account(OrgB) tables),
drag the look up field of Contact into ExternalIdField of Account, in this
way you have link the lookup field of Contact(OrgA) with the
ExternalIdField(OrgB).
8. After that, drag the id field of Account(OrgB) to the Account lookup
field on Contact(OrgB) on the right side of the tMap component, in this
2. way you are inserting the Account(OrgB) id into the lookup field of
Contact(OrgB).
9. Now just run the job, it will insert the contact record and will link
it with the parent record as well in the target org.(OrgB).
Data Loader and relationships
Moving data between two Salesforce Orgs can happen in the context of refreshing a Full Copy Sandbox
instance with data from the Production instance. However, there are cases where data has to be moved
from one Sandbox instance into another, or from a Production instance into a Config/Developer Sandbox.
In such cases, the trickiest part of migrating the data is maintaining the relationships (lookup or masterdetail) between Objects.
For example, take the case of Opportunities and Accounts. Opportunity data exported from the source
Salesforce Org. would have references to Account ID’s that are specific to the source Org. When trying to
import this data into the destination Salesforce Org, those IDs would not exist and the Opportunities
would therefore not be associated with their respective Accounts.
A combination of External Id fields and the Data Loader ‘Upsert’ command can however move data from
one Salesforce Org to another while maintaining all relationships. Using the Opportunity and Account
standard Objects as an example, the step-by-step process is as follows:
1) In the destination Organization, on the Parent Object (in this case, Account), create a new field of type
Text and mark it as an ‘External Id’ field. Be sure to make the length of the field at least 18 characters
(the size of the Salesforce ID field). Let’s call this new field on Account – ‘Source Acct ID’.
2) Export the Parent Object (in this case, Account) data from the source Organization into a csv file using
Data Loader. Be sure to include the ‘Id’ field when exporting this data.
3) Insert the data from Step 2 into the destination Organization using Data Loader. In the mapping screen
of Data Loader, map the ‘ID’ field from the csv file to the new field created in Step 1 (in this case,
‘Source Acct ID’).
4) Export the Child Object (in this case, Opportunity) data from the source Organization into a csv file
using Data Loader. Be sure to include the relationship field (in this case ‘AccountID’) when exporting
this data.
5) Upsert the data from Step 4 into the destination Organization using Data Loader. In Step 2a of the Data
Loader, select ‘ID’ as the field to use for matching Opportunities. In Step 2b of the Data Loader, select
the field created in Step 1 (in this case, ‘Source Acct ID’) as the field to match the parent object. In the
next mapping step of the Data Loader, map the ‘AccountId’ column of the csv file to the ‘Account:Source
Acct ID’ field. This will allow the Data Loader to associate each Opportunity record with its respective
parent Account record. Note that the ‘AccountId’ column of the CSV file should NOT be mapped to the
3. standard ‘AccountId’ field (which is what the Data Loader does by default with the ‘Auto-Match Fields to
Columns’ option). Instead, it has to be mapped to the ‘Account:Source Acct ID’ field.
6) After finishing the data import, the new field created in Step 1 (‘Source Acct ID’) may be deleted as it
was only necessary for the data import process.