+ Start a Discussion
Manoj Kumar TiwariManoj Kumar Tiwari 

Data Import Wizard error "INVALID_FIELD:Foreign key external ID: ....."

W. r. t. to the URL 
https://developer.salesforce.com/docs/atlas.en-us.200.0.fundamentals.meta/fundamentals/adg_relationships_dl_sample_data_try_it_out.htm
I am working with "Data Import Wizard" to import csv files into custom objects "Candidate", "Position" and "Job Application". I followed the isntructions as specified in "Try It Out: Download Sample Data". I have been able to import Candidate and Position records. However it is consistently failing on "Job Application" object. To understand the process, I am attaching the screen shot.

Final outcome is in the result file generated by the wizard and is as follows:
"Id","Success","Created","Error"
"","false","false","INVALID_FIELD:Foreign key external ID: george@schnell.com not found for field First_Name__c in entity Candidate__c:--"
"","false","false","INVALID_FIELD:Foreign key external ID: dcarroll@merce.com not found for field First_Name__c in entity Candidate__c:--"
.....

What is wrong with my process? Please suggest.  Thanks in advance for your kind help in this regards.

Data Import Wizard Image 1

Data Import Wizard Image 2

Data Import Wizard Image 3
Ritesh AgrawalRitesh Agrawal

Hi, 

I faced same issue, not sure what is causing it. But I found a workaround solution that worked for me.
This helped me to move forward on building the App.

Step1. Extract all records for 'Candidates' record. Make sure your extract file have ID (Salesforce ID) & eMail column in it.
Step2. Replace the eMail IDs in Job_Applications.csv file with the corresponding Salesforce ID of Candidates record obtained from above extract.
Step3. Save Job_Applications.csv file
Step4. Import the newly saved Job_Applications.csv file using Data Import Loader. Select "Which field on Candidate...?  SalesForce ID"

Hope this works for you too.

Thanks!

Hardie Botha 3Hardie Botha 3

I have the same problem.  The whole point of the exercise is to use the External ID to identify the correct record.  The workaround allows you to continue, but it does not address the issue.  

Can External ID's be used at all to locate record?  The dialog presented is different from what the course material describes.  In the course material, you are instructed to select the matching field on "Candidate" to be Email (External ID).  That option is not available, you can only select "External ID" and cannot specify a field.  If you followed the book, you should have 3 External ID fields defined, First_name, Last_name and email.  Salesforce then unsuccessfully tries to match against the first external ID it encounters, which is First_Name__c and fails to find a match, predictably.  It seems that it does not try to match against ALL external ID's in the absence of the ability to select a particular external ID.  

The request made for the import is this:
"Candidate__r.First_Name__c","Position__r.Name","Status__c"
"george@schnell.com","Documentation Writer","Phone Screen"

The result is then:
"Id","Success","Created","Error"
"","false","false","INVALID_FIELD:Foreign key external ID: george@schnell.com not found for field First_Name__c in entity Candidate__c:--"

The web interface does not supply you with a means to select the correct External ID if there are more than one option.
The only way I could get this to work with external ID's was to make sure there is only one - the correct one.

TL;DR

Remove the External ID checkboxes from Last_name and First_name.

This results in the request changing to:
"Candidate__r.Email__c","Position__r.Name","Status__c"
"george@schnell.com","Documentation Writer","Phone Screen"

With the result:
"Id","Success","Created","Error"
"a0C41000000Udq1EAC","true","true",""

And you have inserted records by using an external ID on the lookup field.
 

Sanrio AlvaresSanrio Alvares
Hi,
I am having the same foreign key issue. In my case I am not able to select the External Id in the drop down itself. I have changed the candidate object to have just one external Id i.e. Email and changed FirstName and Last Name to text. Can anybody throw any light on this?
User-added image
Avinash Patil 38Avinash Patil 38

For uploading the data you need to define email id in candidate object as unique.
Then you will get an option Email(External ID) in data import wizard. Rest process is same as the book.

 

Step 1) Setup>Find>Object>Candidate>Email>Edit>Do not allow duplicate values

Step 2) Setup>Data Import Wizard>Custom Objects>Job Applications>Add new records>Candidate Field>Email(External ID)>Position Field>Position Name>Next>Map Postion object with Position and Cadidate with Candidate>Next and VIOLA.

Dhrumil ShahDhrumil Shah
For Importing Job Application make Email field TRUE for Unique and External ID in Candidate Object. 
KkngKkng
How to set email field TRUE for unique?
Harsh AhujaHarsh Ahuja
I am also facing the problem but won't be able to solve it so please help me out