Find your content:

Search form

You are here

Can I import child records using the parent's External ID?


I have a bunch of data I want to import into a custom object. I need these records to have a look up to the Account.

The Account has an External ID which is also present in the data I'm importing. Can I create child records referencing the External ID and not the Account ID?

This will be a fairly frequent data import so I would rather not have to do any manual matchup in Excel to get the Account ID.

The only option I can think of is to import with External ID listed in my custom Object and run a batch Apex job to do the referencing and populate the lookup field with the Account ID.

Attribution to: Salesforce Wizard

Possible Suggestion/Solution #1

Using, you can do an import and use the lookup functionality to find the correct record. For example, let's say you have the account external ID and are inserting into Contacts. On the mapping screen, map the external ID to "Account ID." Then choose the select box which says "Lookup using Account" and select the external ID field.

For more information, see this overview of the lookup capabilities.

Attribution to: Dan Diephouse

Possible Suggestion/Solution #2

Data loader is your friend, and has functionality geared for this specific requirement. In addition, if you were loading from a batch process like you mentioned, you'd create your objects in a fashion similar to new MyObject__c(My_Relationship__r = new My_Relationhip_c(MyExternalIdField_c=...));

Attribution to: James Loghry

Possible Suggestion/Solution #3

Yes. For example, using the REST API and the forcetk library you would pass an Account object with the external id field populated:

client.create('Contact', {
  Account__r: {External_Id__c: 'my account id'},
  FirstName: 'Salesforce Wizard'

Attribution to: xn.

Possible Suggestion/Solution #4

Yes, using the data loader you can look up to another record based on an external ID. However, note that the ID should be flagged as unique too.

This would also be doable via the API.

Attribution to: David Gillen
This content is remixed from stackoverflow or stackexchange. Please visit

My Block Status

My Block Content