+ Start a Discussion

how to upload the self-parent(a object looks up itself) object using data loader

Hi Guys,


I have to upload a self-parent(a object looks up itself) object using data loader.  


For example, we have 5 level location information.  Suburb, Area, Regional, State, Country.


The CSV file looks like below


Id,                                   ParentId            --------------------------- column name


StateId,                         countryId

RegionalId,                  StateId

AreaId,                          RegionalId

SuburbId,                     AreaId


The number of records in that CSV file is more than 5k. 

I got some errors like "without foreign key" when I upload the csv file with "upsert" operation.(I tried to upload small number of data with batch size one, and it succeeded)


I guess that salesforce cannot insert a record and upsert the secord record (based on the first record Id) in same batch process(batch size is 200), In other word, the parent and child records should not be included in the same batch.  But I couldn't split it into 5 different CSV files based on the location type(Suburb, Area, Regional, State, Country). 


Is there any way I could work around this issue?


Thanks in advance.






Sumit KumarSumit Kumar

Try below link may you got yours answer



Sumit KumarSumit Kumar

First upload all the records by leaving the self parent look up field blank, then export the all record update the self parent look up field by  the id of the parent record then update the sheet