3

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.

0

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.

0

For a custom object when you insert a custom field, you need to set one of the custom field as ExternalID in salesforce (Edit your custom field and set it as ExternalID)

Now while upserting pass this ExternalID column name (the actual name i.e. with __c) in CSV or XML.

Please revert for any other help.

0

As it turns out, the solution was simply to modify the header in the CSV file, rather than attempting to perform any java manipulation.

Using the following value in my CVS feeder file, resolved the issue:

Invoice_Reference_ID__r.Invoice_Reference_Number__c

Thank you to all for reading my question, and to those who responded. Problem solved.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.