[SalesForce] Java BulkAPI exception: Field name provided does not match an External ID

This posting is in reference to this webinar and it's associated Java code regarding use of the Bulk API.

  1. Salesforce API Series: Fast Parallel Data Loading with the Bulk API
  2. salesforce-bulkAPI-parallelism

I have been able to successfully use this sample code to "insert" data into my primary custom object "Invoices". This object has an external id defined as "Invoice_Reference_Number__c" (API Name).

The second object is called "Devices" and has a Master/Detail field called "Invoice_Reference_ID__c" which references the "Invoices" object.

I have been able to successfully load data into the Devices object using the Data Loader and by specifying the relationship in the mapper as:


File Column Header: Invoice_Reference_ID__c
Name: Invoice_Reference_ID__r:Invoice_Reference_Number__c

I modified the Java code to allow an "upsert" by doing the following:


if (operation.equals(OperationEnum.upsert))
job.setExternalIdFieldName(externalFieldName);

The problem I'm having, is that when I use this same externalFieldName as displayed in the Data Loader to the Java program, I get the following error:


exceptionMessage='Field name provided, Invoice_Reference_ID__r:Invoice_Reference_Number_c does not match an External ID for Devices_c'

I'm a little confused why the error suggests the external Id is on the "Devices" object.

I've tried a few combinations of this external id to the java app, to no avail.
I don't quite understand why the Data Loader works just fine and the Java app doesn't like it.

Any help would be appreciated.
Let me know if there is any further information I can provide to help you help me.

Thank you.

Best Answer

My guess - try with this scenario. When you are upserting you need to use the external ID of the object what you are importing. Also you need to provide reference to the parent object as it is related with Master detail relationship.

Related Topic