Migrating files and data · 7 min read

Salesforce Data Migration Best Practices: 10 Rules for Moving Records Between Orgs

Published · By Edward Elliott

Moving records between Salesforce orgs looks like a copy, but every record gets a new ID in the target org, every lookup has to be rewritten to point at those new IDs, and every trigger, flow and sharing rule in the target org runs against your load unless you plan for it. These ten practices come from Salesforce's own guidance on large data loads and from what goes wrong when it's ignored.

1. Give every record an external ID

Record IDs belong to the org that created them. Salesforce's advice for org-to-org migrations is to create a custom External ID field on each object and populate it with the source org's record IDs. That field becomes the key for everything that follows: matching, relationships, re-runs and rollback.

  • Store the 18-character source ID. The 15-character form is case-sensitive, so two different records can look the same to a case-insensitive match.
  • Load with upsert on that field. Salesforce's upsert rules are simple: no match creates a record, one match updates it, and more than one match is an error. That makes a failed load safe to run again.
  • Keep the external ID unique within each file. If the same value appears twice in one batch, both rows fail.

Each object can have up to 25 external ID fields, and fields marked Unique count toward that limit.

2. Set relationships by external ID, not by record ID

You don't need to look up target IDs for every lookup field. The Bulk API accepts a parent's external ID in the CSV header, using the relationship name and an indexed field:

Legacy_Id__c,LastName,Email,Account.Legacy_Id__c
0035e00000AbCdEFGH,Okafor,n.okafor@example.com,0015e00000XyZaBCDE

Salesforce resolves Account.Legacy_Id__c to the target account's ID as it loads. Polymorphic fields such as a task's WhatId need the object type as a prefix (ObjectType:RelationshipName.IndexedFieldName). One rule to plan around: with upsert, the parent record must already exist.

3. Load parents before children

Every parent has to be in the target org before the records that point at it. Salesforce publishes a recommended load order, and its API guide adds that you should load users first. For a typical Sales and Service org that works out like this:

A typical load order; custom objects slot in after whatever they look up to. Self-lookups (dashed) are filled in a second pass.

Self-lookups need that second pass because you can't add a record that references another record of the same object type in the same call. Load the accounts without ParentId, then update ParentId once every account exists. Salesforce's own knowledge articles list slightly different orders, so treat any published sequence as a starting point: what matters is that each object's parents are loaded first.

4. Make the target schema match before any data moves

Most row failures in a first load are schema differences: a field that doesn't exist in the target, a picklist value it doesn't know (restricted picklists reject unknown values), a record type that's missing, or a field that's required in the target but empty in the source. Compare objects, fields and picklist values between the two orgs and fix the target first. That is also the moment to add the external ID fields from practice 1.

5. Decide what automation runs during the load

Triggers, flows and validation rules in the target org fire on migrated records just as they would on new ones, which slows the load and can change the data. Salesforce's large-data-volume guide says to "disable Apex triggers, workflow rules, and validations during loads" and process records afterwards with batch Apex. Two details matter:

  • You can't switch automation off from Data Loader: Salesforce says it is "currently not possible to disable" workflow rules and processes for a Data Loader upload. Workflow rules and Process Builder are no longer supported since December 31, 2025, but existing ones keep running.
  • Build a bypass instead. Salesforce's architects call custom permissions "the modern, scalable standard" for bypass logic: triggers, flows and validation rules check for a custom permission, and only the migration user has it.

Whatever you bypass, list it, and run it afterwards: roll-up values, derived fields and anything a skipped flow would have set.

6. Choose the API and batch settings deliberately

For large loads, Bulk API 2.0 is the default choice. Its limits are generous (150 million records per rolling 24 hours, and 15,000 batches shared with the original Bulk API), but how it processes records shapes what you send:

  • Keep each upload under 100 MB. A job takes 150 MB, but base64 encoding adds about half again.
  • Salesforce splits uploads into batches of 10,000 records. A batch that isn't finished within 5 minutes fails and is retried, up to 20 times. Heavy automation is the usual cause.
  • Bulk API 2.0 runs batches in parallel only. Parallel loads can collide on the same parent record; Salesforce recommends grouping child records by parent in the same batch. For the operations it lists as lock-prone, such as creating users or changing ownership under private sharing, it suggests the original Bulk API in serial mode.
  • Insert is the fastest operation, then update, then upsert. Where you know which records are new, split an upsert into an insert and an update.
  • Clean the data first. Errors in a batch trigger single-row processing for that batch, which is much slower.

7. Preserve owners and audit fields

Without extra permissions, every migrated record shows the migration user as its creator and the migration date as its created date. Two permissions fix that:

  • Set Audit Fields upon Record Creation lets the API set CreatedDate, CreatedById, LastModifiedDate and LastModifiedById. It works only when the record is created; you can't change these fields afterwards. Grant it through a permission set, because standard profiles can't receive it.
  • Update Records with Inactive Owners lets you load and update records owned by users who no longer work there, which matters when history comes across with its original owners.

Map owners by user ID, not name: Salesforce can't match an inactive user by name during an import. And test audit fields with the operation you'll really use: one Salesforce article says they can be set on insert but not on upsert, while another describes upserting them.

8. Keep sharing calculations out of the way

Every record you load into an org with private sharing triggers sharing work. For an initial load into a new org, Salesforce suggests Public Read/Write during the load and loading roles before sharing rules. When the target org is already live, look at deferring sharing calculations instead:

  • It isn't on by default; you ask Salesforce Customer Support to enable it, and the user needs Manage Users and Manage Sharing Calculation Deferral.
  • It doesn't defer everything. Manual shares, team and queue changes still calculate immediately.
  • When the load is done, resume the calculations and run a full recalculation.

Watch ownership too. Salesforce recommends that no user owns more than 10,000 records and no parent has more than 10,000 children. Assigning everything to one migration user breaks the first rule on day one.

9. Rehearse in a Full sandbox

Run the whole migration at least once against a copy of the target org, and time it. Salesforce says only Full sandboxes support performance and load testing:

SandboxWhat it copiesRefresh interval
Developer, Developer ProMetadata only1 day
Partial CopyMetadata and a sample of data (up to 10,000 records per object, 5 GB)5 days
FullMetadata and all data29 days

The rehearsal gives you the run time for the cutover plan, the error rate per object, and a list of mapping fixes. Use a sandbox refreshed recently, so it matches the production configuration you'll be loading into.

10. Validate, and plan the way back

Decide before the load how you'll prove it worked and how you'd undo it:

  • Counts per object in source and target, within the migrated scope.
  • Samples: a handful of records per object, compared field by field, with their related records.
  • Duplicates. Duplicate rules in the target can block API loads: with an alert rule, records sent through the API simply aren't saved. Records in the same batch aren't compared with each other either, so de-duplicate the source before you load.
  • Rollback. Because every migrated record carries its source ID in the external ID field, you can find and delete exactly what the migration created.

Want the ten practices built into one workflow?

Salesforce Data Migration compares schemas, creates missing fields, remediates permissions, then migrates records in dependency order with external ID mapping and a per-record report.

Explore Salesforce Data Migration

Sources

  1. Migrate data from one organization to another · Salesforce Help
  2. Recommended Salesforce Object Load Order for Large Data Loads and Data Migrations · Salesforce Help
  3. upsert() · SOAP API Developer Guide
  4. create() · SOAP API Developer Guide
  5. Best Practices with Any Data Loader · SOAP API Developer Guide
  6. Relationship Fields in a Header Row · Bulk API 2.0 Developer Guide
  7. Understanding Bulk API 2.0 Ingest · Bulk API 2.0 Developer Guide
  8. General Guidelines for Data Loads · Bulk API Developer Guide
  9. Bulk API and Bulk API 2.0 Limits and Allocations · Salesforce Developers
  10. Loading Data from the API · Best Practices for Deployments with Large Data Volumes
  11. General · Best Practices for Deployments with Large Data Volumes
  12. Record-Triggered Automation · Salesforce Architects
  13. How to Control Workflow and Process Execution When Using the Data Import Wizard vs. Data Loader · Salesforce Help
  14. Enable the 'Create Audit Fields' Permission in Salesforce · Salesforce Help
  15. Defer Sharing Calculations · Salesforce Help
  16. Sandbox Types and Templates · Salesforce Help
  17. Things to Know About Duplicate Rules · Salesforce Help

Related reading

Request a demo