I'm using the data loader. I'm not sure about the use of the Parent id in the picture below.

enter image description here

When have i use this? I'm upserting with the data loader contacts that are related of course to certain accounts. I have an external id common for both objects.

can i use this to match the account related to my contact? is it only for master-detail relationship? can you give me an example of use of the parent id for related object?

Thank you BR.

1 Answer 1


You can use external ids to relate records that you are loading with the parent (i.e. records that they look up to - both Master Detail and Lookup)

Accounts and Contacts is a great example. If you have Accounts loaded in, and they have an External Id Field say External_Id__c, then you can use this field to relate the Contacts you are loading to the Accounts already loaded.

This saves you the trouble of extracting AccountIds and editing your CSV to add them in.

External Ids let you match based on an 'External Id', typically finds uses when you're migrating data from a legacy / external system into salesforce. (Look at it like a Foreign Key or a relationship being imported from an External System)

If you pick the External Id field to relate to parent in this case, it will add a special kind of mapping, which you can see if you save the mapping to a (.sdl) file.

eg in the Account - Contact example, it will read

AccountId = Account\:External_Id__c

What this is saying is populate the Account lookup on the Contact I'm loading by looking up on the External_Id__c field on Account.

You can also use External Ids in Apex

//create an in memory account with the external id set
Account acc = new Account(External_Id__c = 'ABC12345'); 

//set the account instance on the contact to look up via the external id
Contact con = new Contact(Name = 'Smith', Account = acc);

//use upsert to match on external id
upsert con;
  • thanks,you are a life saver.Your example is my real problem:I have Accounts loaded in, and they have an External Id Field say External_Id__c, I use this field to relate the Contacts. i have to set the reference account-contact(with the common external id ) and after set the owneraccount=ownercontact where are equals the external id.Pleace,Can you help me with this?
    – Enry
    Commented Jun 11, 2013 at 18:39
  • You don't need to do that, when you're loading in Contacts, simply choose to relate to Accounts via the External_Id__c field (like your screenshot, pick the External_Id__c from the drop down), and it will take care of the matching for you. Give it a try and let me know if any problems. Commented Jun 11, 2013 at 18:43
  • it works!!.but i 've written about an additional requirement. I must also make sure that the owner of account will be the owner of the contact.how can i do this? thank you so much.
    – Enry
    Commented Jun 11, 2013 at 18:48
  • If the Contact object has 'Controlled by Parent' in the Sharing Settings, it would be owned by the Account Owner, I reckon. Have you changed Sharing Settings for Contact ? If so, a simple before insert trigger on Contact should be able to lookup the Account Owner and set the Contact Owner. Commented Jun 11, 2013 at 18:53
  • Contact has 'Controlled by Parent' in the sharing setting. Have i to write a trigger or i 'am sure that the owner will be the same for accounts and contacts after the import?
    – Enry
    Commented Jun 11, 2013 at 19:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .