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
flewellsflewells 

Foreign key resolution with external ids using the Data Loader

Hi everyone.  Does anyone know how to get foreign key resolution with external ID functionality using the Apex Data Loader? 

I've seen it work (I believe it involved a modified and unsupported jar file), just don't know how to set it up for myself. I've read Simon's posting on Pocket Soap that addresses this topic for the API and Apex, but I'd like to get this working for the Apex Data Loader too.  Any ideas?
SuperfellSuperfell
I believe the latest version of the dataloader supports this directly now.
flewellsflewells
Thanks for the quick reply, Simon, and pointer to the API guide.  I see information about foreign keys, and I'm familiar with using Upsert on the Data Loader, but still coming up empty handed for what I'm trying to do.

I should clarify that what I want to do is import .csv files using the Apex Data Loader to create new records.  If I'm inserting new custom object B records, that have a relationship to custom object A, I want to be able to include my external ID from custom object A, instead of its 15-char salesforce ID, in my .csv file.

It's probably staring me right in the eye.   Can someone help point me to the appropriate topic(s)?

If there's a better way of going about this, please let me know.  Thanks!

GoForceGoGoForceGo

As long as your mapping file (.sdl) maps correctly to foreign keys it seems to wor). You can create this file using the UI version of Data Loader. 

 

So in the process-conf.xml would only reference B's sfdc.externalIdField.

 

<entry key="sfdc.externalIdField" value="B_ID__c"/>

 

The mapping file would have something to effect: 

 

A_ID =A__r\:A_ID__c

 

Where A_ID is the column name in your .csv file, A_ID__c is the external ID for your object A.