[SalesForce] Parent Id Apex Data Loader

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.

Best Answer

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;
Related Topic