Salesforce Integration: Upsert Operation with External Id

Each object can only have a maximum of 3 external ID fields. This external ID field is extremely useful when it comes to integration or migration. If you combine this with the UPSERT operation, you can save the API calls to Salesforce and also speed up the process. Let me show you how it works with the following scenario.


We have a requirement to load a CSV to Salesforce periodically. This CSV file contains Account information.



A normal process routine will check if this Account exists in Salesforce before performing the INSERT/UPDATE operation.



If you have Company ID configured as an External ID, you can directly perform the UPSERT operation.

An UPSERT operation is a combination of UPDATE/INSERT. Salesforce will:

  • perform INSERT if records is not found with the same External ID
  • perform UPDATE if record is found with the same External ID