How to Upsert Data with Data Loader in Salesforce

In Salesforce, we have a robust data management tool, and that is Data Loader. It is more efficient than other data management tools offered in Salesforce. It also has one unique feature to upsert records, which means we can update, insert, or create records within one operation.

In this Salesforce tutorial, I will explain to you the Upsert feature of Salesforce and also the procedure to upsert data with Data Loader in Salesforce.

What is Upsert in Salesforce Data Loader

Upsert is a combination of “update” and “insert.” It allows us to insert new records and update existing ones in a single operation, making data management more efficient.

In Salesforce, Data Loader Upsert is an operation in Data Loader in which we can operate both Updates and Insert to an existing record in Salesforce.

Upsert Data with Data Loader in Salesforce

To upsert the data with the data Loader in Salesforce, ensure you have access to the records in which you want to upsert the data.

In this example, I will explain the data upsert operation by upserting the leads data. Now follow the below steps, to upsert data using the data loader.

1. To update lead data, we need the required fields: Company Name, Last Name, and Status. Now, we need to create a CSV file with these fields, and for that, first, we will export the details of leads in a CSV file with these fields for the reference of creating a new CSV file.

2. To export the leads, open the data loader, log in with your credentials, and click on the Export button. Then select the required fields of Leads, which are Company Name, Status, ID, and Last Name.

Then click on the Finish button to complete the export operation and save the export in a CSV file.

Create a CSV file for upsert data with Salesforce Data Loader

3. Now, from the exported CSV file, copy the Header columns and IDs of the records that you have to update.

Create a CSV file for upsert data in Salesforce with data Loader

4. Create a new CSV file and enter the header column copied from the exported CSV file. Enter the ID of the fields that you have to update, then enter the fields for new records except for the ID field.

You can refer to the below image to create a CSV file for the Upsert operation.

Upsert data with data loader in Salesforce

In the above CSV file, the leads with ID are the ones that will be updated and the lead records without ID are the ones that will be inserted or created in this upsert operation.

5. Open the data loader login with your credentials and click on the Upsert button.