CRM Science Guide to Salesforce Data Loader: History and the Basics
A brief history of Salesforce Data Loader
Long ago, before the dawn of time (or at least before the dawn of my Salesforce career circa 2010), there was Salesforce Data Loader.
I’m speaking about the lovable, Salesforce created, good ol’ Data Loader.
Okay, or “Apexdataloader,” or Force.com Data Loader… we judged not its identity crises, as long as it stood reliably by our side during the endless migrations, implementations, integrations, and backups that we so desperately needed from it.
Salesforce Data Loader was originally only available for Windows. Zulu OpenJDK was introduced as a dependency in Spring ‘19 (v45.0).
It is a tool that lives within Salesforce orgs that’s used for the bulk import or export of data. In this first installment of the CRM Science Guide to Salesforce Data Loader, I’ll cover the history and basics for getting started.
Salesforce Data Loader Predecessors and Alternatives
Since Microsoft Excel is quite prevalent in data file viewing and manipulation, one of the early alternatives to Salesforce’s Data Loader was the sForce connector. The connector is a VBA plugin that utilizes the SForce Office Toolkit, which is an installable component that handles the SOAP API side of things so you can worry about the Visual Basic side.
For Apple users, there was also LexiLoader: an OS X application to fill the void of a natively available Data Loader on Mac written by pocketsoap.com author Simon Fell.
Our hearts go out to Simon Fell for his relentless open-source contribution on many fronts. Beatbox, while being oddly non-musical, was my first on-the-job experience with Python. It is a python module to help call the Salesforce SOAP API.
You are likely familiar with MuleSoft’s infamous cloud-based data importing and exporting tool. This is the stuff that made Salesforce eye-and-buy them.
Whole compendiums can be written about the range of possibilities that this tool provides. That won’t be the scope of this article though.
There are also many great migration tools out there created by third-party vendors, but this article will only be focusing on Salesforce’s own Data Loader with brief references to historical applications and MuleSoft (a Salesforce company as of 2018).
This will help us cover a broad range of topics from trivial to advanced on one tool. No one topic will be covered in extensive depth. However, the goal is not to make you know enough to be dangerous, but rather to take an extra step to get you to know enough to be effective.
Get Code Examples
In order to give you hands-on experience with the Data Loader with simple, consistent steps, I’ve created some data and mapping files hosted on Bitbucket as a Snippet repo.
To limit the scope of this article and to prevent complications in using the code and data samples hosted on Bitbucket, the primary branch has been left the default of “master.” I recommend referring to GitHub’s repository or Bitbucket’s blog article to learn more about the reasoning behind and implementation of taking this insensitive term out of your development process.
Salesforce Data Loader Basics
Where to find Salesforce Data Loader
Like the infamous (and now deprecated) AuraDocs Reference App (which was not only org specific but had no link through which to navigate to it), Salesforce Data Loader is only available inside your Salesforce org in the Setup area. So don’t try Googling it.
Either use the handy search in Setup, or navigate to Integrations (in the Platform Tools category) > Data Loader.
Here you will find links to download Data Loader for either Windows or Mac and links to installation instructions for each platform.
I also recommend downloading the full Data Loader Reference documentation here.
During installation, you may encounter screens such as these… Don’t be scared!
There may be things you learn about yourself that you never knew before like what version of MacOS you’re running or that you actually have a 32-bit processor (you rebel, you 🤠).
Don’t worry because you are in good hands. Lean in to your inner hacker.
(If you really want to have a momentary ego boost of hacker-dom, check out hackertyper.net to snag some perfect footage for your next War Games or Sneakers scene.)
Salesforce Data Loader Operations
Salesforce Data Loader supports 7 operations. I invite you to follow along with the samples provided.
You can use a sandbox, developer org, Trailhead playground, or the production org of anyone who says you can use it.
On a serious note, unlike in Apex, there is no rollback available in Salesforce Data Loader and no “--checkonly” attribute you can switch on.
Unless you’re Exporting, you have the power to bork your org in ways that will have you eating pints of Ben & Jerry’s to recover.
However, with great power comes great responsibility — and also capability.
So put your adulting hat on, and follow me on a data journey.
Insert Records in Salesforce Data Loader
The plain and simple creation of records is a fundamental skill to acquire when learning to use Salesforce Data Loader.
Here are some things to consider when getting started:
You’ll need the actual Salesforce ID of records you’re working with to populate lookup and master-detail fields.
Sometimes when you’re creating a series of dependent records (i.e. Accounts, then Opportunities and Contacts), Anonymous Apex may suit you better for repeatable sample data creation.
If you’re using an ID from another system and want to prevent duplicates based on an external ID, then you’ll want the Upsert operation.
Insert Account Records
Let’s insert some Accounts!
Use the following links to access examples for creating Account records. I’ve tried to make these distinct from a usual developer org’s sample data.
Important: Choose a folder to store your success and error files. You’ll need to access these for cross-reference IDs. I recommend the /inserts/insert_results/ folder in the sample repo provided.
Insert Contact Records
Now, it’s time to insert those Contacts!
Remember, the AccountId column is blank. Luckily, the Accounts I’ve included in the sample file are limited and probably unique.
Using your favorite CSV editor (or a magnetized needle and a steady hand), copy the Account ID from the “Salesforce Data Loader” Account record and paste it into the AccountId column for Astro, Cloudy, Appy, and Codey.
Then, copy the Account ID from the “CRM Science, Inc.” Account record and paste it into the AccountId column for Nate, Joe, and Stuart.
(If you’re wondering about the mascot names, then kindly check out this article on “Astro’s Mom.”)
Use the following links to access examples for creating Contact records.
Update Records in Salesforce Data Loader
Have a new field you need to populate on existing records? In some cases, a short Apex script run from sfdx or the Developer Console might be the best bet.
However, if Apex makes you nervous or you’d just rather be in a CSV, no worries.
Let’s update the phone numbers on some of our contacts since we’ve now got their direct lines.
Similar to before, we’re going to need to get the Salesforce IDs of the Contacts to have a reference for updating them.
You can clone the success file of your Contacts insert and VLOOKUP on full name (first name is unique for our samples), or use any number of ways to get those Salesforce IDs on the rows we want to update.
Et voilà! We have individual phone numbers loaded for Contacts that are separate from the corporate number.
Upsert Records in Salesforce Data Loader
You might be familiar with the upsert operation in Apex. This is a great way to insert the records without Salesforce IDs and update the records that have one.
Upsert prevents the creation of duplicate records if there is an external ID when bringing records in from another data source. In Salesforce Data Loader, this will help you during migrations where you have a custom field that’s populated with an external ID.
For this test data load, you will need to create a custom field on Contact, “MyExternalId__c”.
API Name: MyExternalId__c
External Id: true
Make sure permissions are at least enabled for your user’s profile (most likely System Administrator).
Note: If you’ve logged into Data Loader with a certain org before you create this field, then you’ll probably need to log out of Data Loader and log back in. It caches the described information on authentication.
Want to get rid of pesky duplicate records? Made a mistake on a previous insert? Just don’t like a few records?
Well, throw them in the Recycle Bin!
If you really want to send records to the landfill of no-return, then you should use the Hard Delete option with Bulk API mode enabled.
Hard Delete Records
Want to make records vanish without a trace? Maybe you want to completely delete an Approval Process in a sandbox and start over.
This operation will delete records and not keep them in the Recycle Bin. However, it is only available when you enable Bulk API mode in Data Loader’s Settings menu dialog box.
This is by far the easiest and safest operation in Salesforce Data Loader.
Download a copy of records in your Salesforce org for reference, reporting, migration, or to make tweaks and then update.
Export All Records
We get it, you want it all. Regular records, deleted records, undeleted records.
Sometimes you may just be looking for those records someone deleted but didn’t yet empty out of the Recycle Bin. Export All has you covered.
You could successfully use Salesforce Data Loader for years and never save a mapping file or see its innards, so we’ll only cover the basics. Here is a resource with more information. A mapping file enables you to tell Data Loader which column headers in your file correspond to which fields in Salesforce. This can save you considerable time when dealing with column headers that don’t have the exact spelling as the API names of an object’s fields, or when retrying an operation several times (possibly due to errors).
When performing every operation except an Export or Export All with the UI in Data Loader, you will need to create (or load) a mapping between the .csv column header and the API Name of a field for the object you are dealing with.
Summary and Resources
Salesforce Data Loader is a mighty tool for the fast and effective bulk import and export of records in Salesforce orgs. The first step to using Data Loader is to, of course, find it in your Salesforce org. Then, get familiar with using Data Loader to complete basic operations like deleting records in bulk, mapping files, and updating records.
After practicing the basic concepts involved in manipulating records in Salesforce Data Loader, you’ll be on your way to Salesforce developer stardom.
Here are some resources for getting started with Salesforce Data Loader:
Contact CRM Science Salesforce Consultants
Full-time Salesforce developers are great at working with tools like Salesforce Data Loader. However, these concepts often need specialized expertise beyond that of multiple-hat-wearing champions who maintain Salesforce orgs at companies large and small.
To ensure the quality of work, we utilize full-time CRM Science consultants for every single project we take on. We believe this allows the consultant to develop a deeper understanding of the work and the client.
Contact CRM Science Salesforce consultants to chat about your Salesforce projects.