function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Michael OLIVERIMichael OLIVERI 

batch data loader and hierarchical field

Hello,

Currently we update our accounts on salesforce by an automatic batch that use data loader.
We do an insert of our new accounts each day.
Then we recuperate the salesforce ID for each account.
And finally we do an update of accounts.

We would like to use the functionnality upsert to simplify the treatment. We can create an external ID on salesforce with our ID to use upsert.
I doesn't test this part but I have no problem with this.
My problem is because we have a hierarchical field on account.
So if we use our id for an upsert I still need the Salesforce id for the hierarchical field. 
Could we use the external id (our id) for the hierarchical information too please? And how can I do that?

Thanks for your help.
RamuRamu (Salesforce Developers) 
I do not think it is possible to refer the hierarchical field using the external id. At this point, your first scenario (inserting and fetching the SF id's) seems to be the best one.
Michael MeinhardtMichael Meinhardt
Hi Michael,

For what you're trying to do, it would be best accomplished with a before insert/update trigger.

Since there is a batch process to the data loader, if you're exceeding the batch size, you need to ensure that all of the "root" accounts are inserted first, then the first level down (where the parent ID is at the root level), then the next level, etc.  This ensures that the parent account you're referencing has been created before, or at the same time, the trigger executes.  

If you want to avoid writing a trigger, you could schedule a job that creates the hierarchy as well, though that is time dependent on when you're uploading the accounts.
Michael OLIVERIMichael OLIVERI
Hi guys,

Thanks for your reply.

I will see what can I done by trigger.