Learner's Byte logo goes here
+
Oscar IT Solutions logo goes here

"Purana data saath lekar chalna hai. Kachra nahi."

"We must bring the old data along. Not the rubbish." A new system is only trusted if its data is.

  • Which tool?
  • Insert or upsert?
  • What order?
  • Why did 3,000 rows fail?
  • How do we undo it?

Step 13: Data Migration

You will move existing data into Salesforce and out of it safely, using the Data Import Wizard and Data Loader: insert, update, upsert, delete, hard delete, export and export all, with planning, cleansing, external IDs, error handling, reconciliation and rollback.

Organisations
Kaveri Motors (Org C) and Suraksha General Insurance (Org D)
You will build
A migration plan and real loads, using practice files from this workbook
Suggested time
3 live sessions of 90 minutes, plus about 6 hours of practice
AI skills used
Classification, Coding and Automation, Summarization

You are hereSteps 1-4 Requirements and configurationSteps 5-9 DevelopmentSteps 10-11 Test and deploySteps 12-15 Rollout

Hook: go-live Monday, and nobody trusts the data

A dealership loaded its old customer Excel into Salesforce the weekend before go-live. On Monday morning:

  • Priya Sharma appeared three times, once as "PRIYA SHARMA" and once as "Priya Sharma ".
  • 4,000 customers were owned by the admin, because the old owner names didn't match any user.
  • Every birthday was a month out, because 03/04/1990 was read as 4 March instead of 3 April.
  • Nobody could undo it, because nobody had kept the IDs of what was loaded.

Consultants went back to Excel within a week. The data loading itself took one hour. The missing planning cost the whole project.

Byte This: Migration is 80% preparation and 20% loading. Plan, clean, test, then load.

By the end of this workbook, you will be able to

  • Plan a migration: scope, load order, tools, owners and rollback.
  • Choose between the Data Import Wizard and Data Loader.
  • Use insert, update, upsert, delete, hard delete, export and export all correctly.
  • Use External IDs to match records and link parents to children.
  • Prepare files that load first time, and fix the ones that don't.
  • Reconcile counts and totals, and roll back safely.

Concept: the migration lifecycle

Load parents before children

A child record needs its parent to exist first, because it stores the parent's ID. So the order follows the data model you designed in Step 2.

Import Wizard and Data Loader

Rule of thumb: Under 50,000 records of a supported object, with a business user doing it: the Import Wizard. Anything else, including all exports and deletes: Data Loader.

Data Import Wizard, step by step

  1. Go to Setup > Data Import Wizard and choose Launch Wizard.
  2. Choose the object, such as Accounts and Contacts, Leads, or a custom object.
  3. Choose what to do: Add new records, Update existing records, or Add new and update existing records.
  4. Choose how to match existing records, such as Salesforce ID, name, email, or an External ID.
  5. Decide whether workflow rules, processes and flows should run for these records.
  6. Upload the CSV file, and choose its character encoding.
  7. Map each column to a Salesforce field. Fix any unmapped columns.
  8. Start the import. Check progress in Setup > Bulk Data Load Jobs, and you'll get an email when it's done.

Data Loader, step by step

  1. Download Data Loader from Setup > Data Loader, or from Salesforce's developer site, and install it. It runs on Windows and macOS.
  2. Log in with OAuth, choosing Production for a Developer Edition or production org, or Sandbox for a sandbox.
  3. Choose the operation, and the object.
  4. Choose the CSV file, for loads, or write the SOQL query, for exports.
  5. Map the fields. Use Auto-Match Fields to Columns, check each one, and save the mapping as an .sdl file to reuse.
  6. Choose a folder for the success and error files, and finish.
  7. Open the error file: each failed row with the reason. Fix the rows and load only the error file again.

Data Loader settings that matter

Every operation explained

Try it: insert, update or upsert?

Salesforce already holds three customers. You load the file below. Choose an operation and see what happens to each row. The External ID field Legacy Customer ID is marked Unique.

Already in Salesforce

Your file

Preparing data that loads first time

Understand IDs

The preparation checklist

Common errors and their fixes

Reconcile and roll back

  • Count: rows in the source file, minus rows you excluded, equals successes in Salesforce.
  • Totals: sum of amounts, such as booking values, matches between source and a Salesforce report.
  • Samples: open 20 random records and compare every field with the source.
  • Rollback: keep every success file. Its first column holds the new Salesforce IDs, so a Delete with that file undoes an insert. Before any mass update, Export the records first, so that an Update with the export puts the old values back.

Demo: Kaveri Motors

Kaveri Motors is retiring its old dealer management system. Here is the migration plan for Org C.

Practice files

These small files mimic the real ones, including the kinds of mistakes real data has. Download them for Exercise 1.

Build it in Org C

  1. Fields: on Account, create a text field Legacy Customer ID, ticked as External ID and Unique. On Asset, create VIN the same way.
  2. Bypass: assign the Data Migration Bypass permission set from Step 3 to your migration user, so that rules don't block historical data. Add the same custom permission to your flows' entry conditions in Step 14.
  3. Find IDs: with Data Loader, Export the RecordType object with SELECT Id, Name, SobjectType FROM RecordType to get the Person Account record type ID. Export Users the same way, to map owner names to user IDs.
  4. Customers: open customers_legacy.csv. Fix the dates to YYYY-MM-DD, add RecordTypeId and OwnerId columns, then Upsert into Account on Legacy Customer ID.
  5. Read the error file. Fix the rows and upsert only those again.
  6. Vehicles: Upsert vehicles_legacy.csv into Asset on VIN. On the related objects step, match Account by Legacy Customer ID instead of the Salesforce ID.
  7. Seminar leads: import leads_seminar.csv with the Import Wizard, adding them to the Corporate Fleet Seminar campaign.
  8. Reconcile: compare counts and check five records by hand. Record the results in your Migration Pack.
  9. Remove the bypass permission set from the migration user.

Practice: Suraksha General Insurance

Suraksha has much more data, and much more sensitive data. Choose the right tool and operation for each job.

Personal data in files: Migration files are full copies of customer and health data. Store them only on approved encrypted locations, share them with as few people as possible, and delete them when the migration is signed off. Use only invented data in training.

Which tool and operation?

Suraksha's volumes

Not all history belongs in Salesforce. Ten years of closed cases use storage and slow reports. Agree with the client what to migrate, such as the last 2 years, and where older data is archived and how it can be retrieved.

Three exercises

Exercise 1: Load, fail, fix, reload

  1. Download the three Kaveri practice files.
  2. Load them as in the Demo. Expect some rows to fail.
  3. For each failed row, write the error, its cause and your fix in the Migration Pack.
  4. Reload only the fixed rows. Reconcile: source rows, successes, rows deliberately excluded.

Exercise 2: Export, mass update and roll back

  1. Export all open leads: SELECT Id, Status, OwnerId FROM Lead WHERE IsConverted = false. Keep this file safe as your backup.
  2. Copy it, and change the Owner of every lead from one consultant to their manager, as if the consultant left.
  3. Update with the changed file. Check in Salesforce.
  4. Now undo it: Update using your backup file. Check the owners are back.
  5. Delete one test lead, then use Export All with WHERE IsDeleted = true to find it. Restore it from the Recycle Bin.

Exercise 3: Plan Suraksha's load order

Give each object a load position from 1 to 10. Anything that depends on another must load after it.

Build your Migration Pack

This is the document a client signs before go-live. Your work saves in this browser on this device.

Build with AI

AI is excellent at writing SOQL, mapping columns and spotting messy data patterns. It must never see the real data.

Three rules: Give AI the column names and a few invented sample rows, never real customer files. Check any SOQL in your org before trusting it. Never run a delete or update file that you haven't opened and checked yourself.

Reflect and exit check

Quick test

Exit check: are you ready for Step 14?

What Step 14 needs from you: Flows run on every save, including data loads. Step 14 shows how to keep automations from firing on historical data, using the same bypass permission.

Interview preparation

Practise saying these answers aloud, then use our AI interview agents for feedback.

For your resume and portfolio

Training project: Planned and executed a data migration for a simulated dealership: load order, External ID upserts with parent matching, data cleansing, validation bypass, error handling, reconciliation and rollback, using the Data Import Wizard and Data Loader.

Trainer notes

Open the suggested session plan and coaching notes
SessionCoverStudents leave with
1 (90 min)Hook, lifecycle, tools, operations. Upsert simulator until everyone can predict it. Install Data Loader.Data Loader installed and logged in
2 (90 min)Preparation, IDs, errors. Exercise 1 live: load, fail, fix.Kaveri data loaded and reconciled
3 (90 min)Exercise 2 export and rollback; Suraksha drill; Exercise 3 load order.Migration Pack, reflection and exit check

Common mistakes to catch

  • Dates in DD/MM/YYYY without changing the Data Loader date setting. Use YYYY-MM-DD.
  • Saving CSVs in Excel, which can change leading zeros, long numbers and encoding. Check in a text editor.
  • Using Insert for a second run, creating duplicates. Use Upsert with an External ID.
  • Forgetting to remove the bypass permission after the load.
  • Running hard delete outside a sandbox. Make students explain it before they're allowed to.

Check before each batch

Download the current Data Loader version and confirm its install steps, login options and the list of operations in its menu. The command-line interface is Windows-only, so plan the demo accordingly.