DEV Community

Ahmed HAMMAMI
Ahmed HAMMAMI

Posted on

Import Export Data to Salesforce

One thing you need to know when working with Salesforce, is how to properly mass import/update data into your Org.

In this quick guide, we will see what are our options when it comes to importing many records into Salesforce, and what different obstacles could emerge.

Please, as a rule of thumb, always try these manipulations in your Sandbox, hoping you have one and it is in synch with production.

FIRST

Get your data groomed, put it in an excel sheet with the field API names as column titles.
Check all your object's fields, what fields are required for record creation, check picklist fields active values, check date and numbers format (You can do this using Object manager and going through different fields and objects, or you can use a third party app like Inspector to export the needed object and fields to make sure the API names are correct)
Example:

Image description

SECOND

Make sure you do not have any automation processes(flow, process builder, validation rules) that need to be deactivated/disabled when mass uploading records, is there a bypass user function in your org that needs to be enabled (If you don't know if there are any, or uncertain how to check for this, ask your administrator before moving forward)
for example, in my org I have a on create flow for opportunity object, this flow assigns record types based on some criteria, but when I'm doing a mass import of more than 5000 opportunities, I will probably know the recordtype of the records before inserting, and add that value to my data, so we don't need the flow as it will most certainly clutter our import if it triggers on each record, so we disable it before starting imports and enable it later.

THIRD

Choose which tool you're going to use to import data, there are many.
_Salesforce Inspector
_JetStream
_Dataloader
_Skyvia
I'm sure they will all get the job done, and each one has it's differences and pros and cons, I personally prefer Inspector for data imports, but feel free to explore all the tools, for the sake of this guide, we will use Salesforce Inspector Plugin for demonstration.

Salesforce Inspector:

Add Salesforce inspector plugin to your browser.
Once you have your data file ready and salesforce inspector installed, click on the arrow that appeared on the right of your tab when you are in a Salesforce org, and click " Data import "
Image description

and that will take you to the import window
Image description

Where you will need to chose the type of your data manipulation (insert update or delete) choose the object you want to work on.

Now go to your Excel file, select the data that you are going to import and hit Ctrl+C (copy)

Image description

and then go back to the Data Import tab, click on the rectangle and hit Ctrl+V (paste)
Image description

Image description

Now as you can see, we have our data "Queued", we just need to verify field mapping, that's on the top right, and chose our batch size, and then click import, and wait for results.
When it finishes, Inspector will add 4 columns to your data table to help you read results;
__Status: Succeeded or failed.
__Id: the created record's ID in Salesforce.
__Action: Updated, Inserted, Deleted.
__Errors: if there is an error message to display.
Please note that Salesforce inspector does not make a log file for the results that you could download, so once it finishes, make sure the checkbox is checked, then click on "Copy Excel Format"

Image description

then go back to your excel file, open a new sheet, and hit Ctrl+V(Paste).
that's the only way to keep the log, if you refresh or leave the import tab with the results, that log will be lost, forver!
(if you ever refresh the page by accident or lose the results and you want a quick way to find the inserted records' IDs, click on export data, and then just run SELECT id, field_name, CreatedDate from ObjectName where createdby.name ='Your User Name' ORDER BY CreatedDate DESC and look through these records with the createddate value)

I always add 2 sheets to my original Data file, one for succeeded records, and one for failures.

Batch size: 200 is generally fine if you are not uploading heavy data records with a lot of fields and relationships to other objects.
if your import keeps failing instantly with no clear errors related to data values, try bringing the batch size down and try again.

Top comments (0)