+ Start a Discussion

Specifying relationship in CSV when using Bulk API

I have Site__c and Property__c objects, each having a lookup to the other. I'm importing data into SF using a Java app written against the Bulk API. Now, I first insert Site__c objects into SF, collect their IDs, and now want to specify the relationship to a Site__c when I insert a Property__c.


I've been trying this in my CSV for Property objects, but it fails:



a07Q0000000YkNAIA0    <=== ID of Site__c object that has already been populated into SF.


The error I get says:


Failed with error: INVALID_FIELD:Field name provided, Id is not an External ID or indexed field for Site__c:--


Note: each of Property and Site have a "LookUp" relationship with each other.


Any suggestions?


On your Property object, you have a lookup to the Site object.  The lookup field is called "site__c" and you want to set it to an SFDC ID for Property that you know is valid.  Is this correct?


Two thoughts:


First rather than setting


site__r.ID = someSfdcId


You should set


site__c = someSfdcId


So your example:





Should just be





Second -- and this is just an FYI -- if there is an external ID on the Site object that the Property object knows about, rather than using the SFDC ID you can just us that external ID to resolve the relationship using an upsert operation.   I generally prefer this method myself as it means one less thing for me to keep track of.


Hope that helps.