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

Trying to understand upsert from data loader

I am trying to understand upsert from data loader. I ws reading through documentation and came across below


If you are performing an upsert:

  1. Your CSV file must contain a column of ID values for matching against existing records. The column may be either an external ID (a custom field with the “External ID” attribute), or Id (the Salesforce record ID). From the drop-down list, select which field to use for matching. If the object has no external ID fields, Id is automatically used. For more information on external IDs, see Custom Field Attributes. Click Next to continue.
  2. If your file includes the external IDs of an object that has a relationship to your chosen object, enable that external ID for record matching by selecting its name from the drop-down list. If you make no selection here, you can use the related object's Id field for matching by mapping it in the next step. Click Next to continue.

My understanding of this is that, i need to have in my csv file id or an external id field to have match and upsert. If i dont have a reference in csv file for id or external id in the object i want to upsert to then i cant go ahead with upsert? Is step 1 necessary ? Can i do 2 without step1? 


I am not very clear on what step 2 does. can anyone explain it to me?


In my csv file i dont have an id but i have an external id on a related object. Can i perform an upsert?


UPSERT is a combination of UPDATING an existing record by INSERTING a new record.


So lets say your scenario is that you are upserting new Opportunity Products ("chosen object)  to a set of Opportunities (Opportunity is the "object that has a relationship to your chosen object")


Step 2 is referencing that you have the external Opportunity IDs of all of the Opportunities you want to add products to. You just need to map the Opportunity ID accordingly in the data loader. This basically tells data loader where to INSERT the new product to UPDATE the existing Opportunity.


Does this help?