I have some accounts where ParentId is null which I want to populate. Here is my csv sample data

enter image description here

So I want the record to be associated with Account1 which has ExternalId__c as "4ab1dc5e-24cc-1405". Let's say that Account name is Account2 so I need Account1's ParentId as Account2's Id.

While doing the upsert I am selecting

The field for matching on Account: ExternalId__c
choosing related object: Parent -> ExternalId__c

Then in mapping screen:

ExternalId__c -> ExternalId__c
parent_id -> Parent:ExternalId__c

the result says successful but the ParentId of Account1 record is not populated with Account2's Id.

Can anyone help, what I'm doing wrong?

  • Could be a stupid question, have you marked ExternalId__c field as External Id?
    – Raul
    Commented May 22, 2019 at 12:47
  • @Raul Yes, that's why the field is appearing in "select the field for matching on Account" as I mentioned. Commented May 22, 2019 at 12:49

2 Answers 2


The ParentId on Account1 won't have been set because it refers to the ID of Account2 in the source org, not the org we're upserting into. Account2 might not even exist at the time Account1 is created, meaning there's no record to set the ParentId to.

To workaround this, you'll need to do a few steps:

  1. Upsert the Accounts without ParentId, creating Account1 and Account2 in the target.
  2. Create a new CSV containing the Id field and the ParentId, where these ID fields are the IDs created in step 1, not the IDs from the source org.
  3. Update the Accounts with this new CSV file, to set the ParentId on Account1.

If you have records with the ParentId set in a Salesforce org, Gearset has a data deployment feature which allows you to do all of this in one operation. Full disclosure: I'm a software engineer at Gearset.

It does this by breaking the operation into a few parts:

  1. Fetch Account records which match a filter (or up to 30,000 records).
  2. Fetch any Account records which are parents of the records in step 1.
  3. Upsert the Account records without setting the ParentId.
  4. Update the Account records to set the ParentId field.

This is the same as the method described above, but you don't need to worry about IDs yourself.

There's a 30 day free trial if you'd like to give Gearset a go. Feel free to get in touch if you have any questions!

Here's a summary of how to do the deployment in Gearset.

Select the source org (which has the ParentId set) and the target org (which has a null ParentId).

Select the source and target org

Select the Account object. You can optionally filter which Account records will be deployed if you're only interested in deploying a subset of the records.

Select the Account object

Select upsert records for Account and choose ExternalId__c as the field. This external id must exist in both the source and target org.

Upsert Account using your external id field

Click to deploy. Gearset will fetch any Account records matched by your filter (or up to 30,000 records if there was no filter) and any Account records which are a parent of those initial records. Gearset will then upsert all of these Account records, and update the records to set the ParentId.

Gearset will upsert Account records and set the ParentId


Data Loader cannot do this in one pass because the the parent account may be in a later group of records that is inserted, so the ID won't be available for earlier groups.

You have to do the insert first and ignore the ParentId. Then you upsert the resulting success file, map the newly created account ID to the ID field in Salesforce, and map the csv external ID field to the ParentId field in Salesforce.

You must log in to answer this question.

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