function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
JoannaJoanna 

Importing Data Into Salesforce

I have been able to use the Apex Data Loader to insert and update Opportunity data into Salesforce.  I set a custom field "Master_Opp_ID__c" as the External ID so that I could have the Salesforce unique identifier the same as the identifier in my company's database.  That worked great. 

The problem came in when I tried to import Subopportunity data (a custom object with a Master/Detail relationship with Opportunities).  I received the error "Required fields are missing: [Opportunity__c]".  Opportunity__c is the Master/Detail custom field on the Subopportunity object.  In the Apex Data Loader, it is of type reference.

My question is how can I import this data while preserving the Master/Detail relationship of the data?  My source database knows the Master_Opp_ID, and I have included that data in my .csv file for the Subopportunity import.  After I got the error, I tried mapping the Master_Opp_ID data to Opportunity__c, but as I expected, it did not work.  I then got the error "Opportunity: id value of incorrect type:".  So, Salesforce must be using its own identifier to for this Master/Detail relationship.  Is there any way that I can specify that they are linked based on the Master_Opp_ID__c field?  After all, it is the External ID field that I have set up for the Opportunity object.

Thanks so much.
RickyGRickyG
Joanna -

If I understand your question correctly, you are almost there.  You will want to do an upsert with Data Loader.  You will be prompted as to which field you want to use, when you would specify the external ID.  This is one of the key use cases for upsert.

Hope this helps.

JoannaJoanna
Excellent!  Thank you for your help.  I was able to find it and perform the import.