Sub topic 12
Safe import practices
This chapter assumes you can prepare a CSV file, map fields, and run an insert or update with the Data Import Wizard or Data Loader. It covers the habits that keep a bad import from damaging your org's data.
Why imports need extra care
An import writes many records at once. A wrong column mapping or a bad filter can overwrite thousands of values in one run. Some changes, such as updates, can only be undone if you kept the old values. Deleted records go to the Recycle Bin, but that is a short-term safety net and not a backup.
A safe import workflow
1. Back up before you change anything
Before an update, upsert, or delete, export the records you are about to touch. A Data Loader export gives you both the record IDs and the current values.
SELECT Id, Name, Phone, Industry FROM Account WHERE Industry = 'Energy'Save the exported file with a date in its name. If the import goes wrong, you can run an update with that file to restore the old values.
2. Test in a sandbox first
A sandbox is a copy of your org used for testing. Run the full import there with a realistic sample of your data. This shows you problems with required fields, validation rules, triggers, and flows before they reach production. Remember that automation runs during imports. A flow that sends an email can send many emails.
3. Start with a small batch
Take the first 10 to 20 rows of your file and load only those. Open the records in the org and check that each field has the value you expect. Then load the rest.
4. Check the results files
Data Loader writes a success file and an error file for every run. Review both. The success file lists the new record IDs, and the error file gives a message for each failed row. Fix the cause in the CSV, then load only the failed rows again, not the whole file.
5. Verify after the full load
Compare counts. The number of rows in your CSV should equal the success rows plus the error rows. Then run a report or a SOQL query to confirm that the data is correct in the org.
Common risks and how to reduce them
| Risk | What happens | How to reduce it |
|---|---|---|
| Wrong column mapping | Values land in the wrong fields | Review the mapping screen, and test with a small batch |
| Duplicate records | The same record loads twice | Use upsert with an external ID, or check matching settings in the wizard |
| Triggers and flows fire | Unwanted emails or field changes | Test in a sandbox, and check the automation on the object |
| Date and number formats | Values are rejected or misread | Use consistent formats, and check the error file |
| Spreadsheet changes | Leading zeros are dropped and long IDs are altered | Check the CSV in a text editor before loading |
| Using the wrong org | Test data lands in production | Check the org name when you log in |
Extra habits for large loads
- Keep a copy of the exact CSV that you loaded, along with its success and error files.
- Load in a quiet period if the object has heavy automation.
- Do a delete only after you have exported the records and checked the list of IDs.
- Use a dedicated integration user so you can see in the record history which changes came from the import.
Exercise
You need to update the Industry field on 5,000 accounts. List the steps you take before and during the load to keep it safe.
Show answer
Export the affected accounts with Id and current values and save the file as a backup. Run the update in a sandbox first. Load a small batch of 10 to 20 rows in production and check the records. Review the success and error files. Then load the rest, fix any failed rows, and verify that success plus error counts equal the row count of the CSV.
Exercise
A load finishes with 4,800 success rows and 200 error rows. What do you do with the error file?
Show answer
Read the message on each failed row, correct the cause in the data or mapping, and load only the corrected rows again. Do not reload the whole file, because that would repeat the 4,800 successful changes and, for an insert, create duplicates.