Sub topic 10
Reading success and error files
This chapter assumes you have run at least one Data Loader operation (insert, update, upsert, or delete) and know how CSV columns map to fields. It explains the two result files Data Loader writes, how to read them, and how to fix failed rows and reload them.
What Data Loader produces after a run
When an operation finishes, Data Loader shows a summary dialog with the number of rows that succeeded and the number that failed. It also writes two CSV files to the folder you chose on the last step of the wizard:
success<timestamp>.csvholds every row Salesforce accepted.error<timestamp>.csvholds every row Salesforce rejected.
Each input row ends up in exactly one of these files. If you load 1,000 rows and 12 fail, you get 988 rows in the success file and 12 in the error file. A file may be empty (header only) if every row went the other way.
The default names include a timestamp, so repeated runs do not overwrite earlier results. Keep them. They are your audit trail for what changed and when.
Anatomy of the success file
The success file repeats every column from your input file and adds two columns:
| Column | Meaning |
|---|---|
| `ID` | The 15- or 18-character Salesforce ID of the record that was created or changed. |
| `STATUS` | The outcome, such as `Item Created`, `Item Updated`, or `Item Deleted`. |
For an insert, the ID column is the only place you learn the new record IDs. Save the success file if later steps depend on them. For example, you might insert Accounts first and then use the new IDs as AccountId values on Contacts.
Here is a success file for the insert file shown earlier in this tutorial:
"ID","STATUS","Name","Phone","Industry","Website"
"001Hs00003AbCdEIAV","Item Created","Acme Corp","555-0100","Manufacturing","https://www.acme.example"
"001Hs00003AbCdFIAV","Item Created","Globex Ltd","555-0101","Technology","https://www.globex.example"A row in the success file means Salesforce accepted it. It does not mean the data is what you intended. A wrong value in a valid format succeeds silently, so spot-check a sample against the source.
Anatomy of the error file
The error file also repeats your input columns, and adds a single column named ERROR. That column holds the message from Salesforce explaining why the row was rejected.
"ERROR","Name","Phone","Industry","Website"
"REQUIRED_FIELD_MISSING:Required fields are missing: [Name]:Name --","","555-0102","Retail","https://www.initech.example"
"INVALID_OR_NULL_FOR_RESTRICTED_PICKLIST:Industry: bad value for restricted picklist field: Mining2:Industry --","Hooli","555-0103","Mining2","https://www.hooli.example"The error message has a consistent shape:
- An error code in capitals, such as
REQUIRED_FIELD_MISSING. - A human-readable message describing the problem.
- The field name or names involved, followed by
--.
The three parts are separated by colons. The error code is the quickest thing to scan and sort by.
Common error codes and their fixes
Most failures fall into a few families. Sorting or filtering the error file on the ERROR column, then fixing one family at a time, is faster than going row by row.
| Error code | Typical cause | Fix |
|---|---|---|
| `REQUIRED_FIELD_MISSING` | A required field is blank or the column is not mapped. | Fill the value, or map the column. |
| `INVALID_OR_NULL_FOR_RESTRICTED_PICKLIST` | The value is not in a restricted picklist. | Correct the spelling, or add the value to the picklist. |
| `STRING_TOO_LONG` | Text exceeds the field's length limit. | Shorten the value, or confirm the field length. |
| `INVALID_FIELD_FOR_INSERT_UPDATE` | The field cannot be written, for example a formula field or a field you lack permission to edit. | Remove the column from the mapping. |
| `INVALID_CROSS_REFERENCE_KEY` | A lookup ID refers to a record that does not exist, or has the wrong object prefix. | Check the related ID against an export. |
| `MALFORMED_ID` | An ID is not 15 or 18 valid characters. | Look for truncated or padded values, which spreadsheets often cause. |
| `DUPLICATES_DETECTED` | A duplicate rule blocked the save. | Review the matches, or change the rule behavior if appropriate. |
| `FIELD_CUSTOM_VALIDATION_EXCEPTION` | A validation rule rejected the row. | Read the rule's message and correct the data. |
| `ENTITY_IS_DELETED` | The record was deleted before the update ran. | Remove the row or restore the record. |
| `UNABLE_TO_LOCK_ROW` | Another process held a lock on the record. | Retry the failed rows, and consider a smaller batch size. |
The FIELD_CUSTOM_VALIDATION_EXCEPTION message text is whatever your administrator wrote in the validation rule, so it varies from org to org.
Error messages sometimes mention a trigger, flow, or other automation that raised the error. Salesforce evaluates this automation on each saved record, so a failure there points to an org customization and not to your CSV format.
Partial success and why it matters
By default, Data Loader reports results per row. Rows that pass are saved even when others in the same batch fail. After a run, your org is in a partially loaded state. This has two consequences:
- Do not reload the whole original file to "fix" a failure. Rows that already succeeded will be inserted again as duplicates.
- Use the error file as the source of the next run, so you only process the rows that still need work.
An exception is the behavior of some automation. If an Apex trigger or a flow uses all-or-none logic, one failure can roll back related records. Rows may then show errors that mention another record in the batch. When many rows fail with a similar message you did not expect, look for one root cause row, fix it, and retry.
Fixing and reloading failed rows
The error file cannot be loaded as is, because it contains an ERROR column that does not map to any field. Follow this process:
- Open the error file in a spreadsheet or text editor.
- Fix the data problems, using the
ERRORcolumn as a guide. - Delete the
ERRORcolumn. For update, upsert, and delete runs, keep theIdcolumn or the external ID column. - Save as CSV with UTF-8 encoding.
- Run the same operation again with the corrected file.
- Repeat until the error file is empty.
Keep each fixed file under a new name, such as accounts_retry1.csv, so the history stays clear.
Note that in an insert error file, the ID column is not present, because no record was created. In an update error file, the Id column from your input is preserved as it was.
Characters, encoding, and spreadsheet side effects
Many errors come from the spreadsheet, not the data. Watch for these when you reopen result files:
- Leading zeros in values such as postal codes or phone numbers disappear when a spreadsheet treats them as numbers. Format those columns as text before saving.
- Long IDs can be altered. Opening a file in a spreadsheet and saving can turn an 18-character ID into scientific notation or trim it, which produces
MALFORMED_ID. - Dates may be reformatted to your locale. Use a consistent format, and confirm the date format in the Data Loader settings.
- Encoding problems turn accented characters into odd symbols. Save as UTF-8 and enable the UTF-8 option in Data Loader settings if you load non-English text.
If a file looks fine but fails, open it in a plain text editor to see what the loader actually reads.
Reconciling counts
After each run, check that the numbers add up:
input rows = success rows + error rowsIf they do not, the likely reasons are blank lines in the input file, a column containing an unescaped quote or line break that split a row, or a run that was stopped partway through. Data Loader writes results for processed rows only, so an interrupted run leaves unprocessed rows in neither file.
For a stronger check after an update, export the changed records and compare them with what you intended. The SOQL query below fits this purpose:
SELECT Id, Name, Phone, Industry FROM Account WHERE Industry = 'Energy'Where to look for failures outside the files
The error file only covers rows that reached Salesforce. Problems can also occur earlier:
- Mapping and parsing errors appear in Data Loader's own dialog or log before any rows are sent, for example a column that cannot be matched.
- Login and connection errors stop the run before any result files exist.
- Data Loader log,
sdl.log, in the Data Loader logs folder, records the run details, including the settings used. Check it when a run behaves differently from what you expected.
For the Bulk API, results are produced after Salesforce finishes the job, so the files may appear a short time after you start the operation. Job-level status is also visible in Setup under Bulk Data Load Jobs.
Why this feeds safe import practice
Results files are most useful when you plan for them before you start. Before a large run:
- Test with a small sample in a sandbox, and read both files.
- Record the expected row count.
- Keep the success file from an insert, since it is the only list of the new IDs and it lets you delete the records if the load turns out wrong.
- Export a backup of existing values before an update or delete.
The next chapters build on these habits.
Exercise
You loaded 500 Contacts with Data Loader. The summary shows 470 successes and 30 errors. A colleague suggests fixing the 30 problems in the original file and loading all 500 rows again. What is wrong with this plan, and what should you do instead?
Show answer
Loading all 500 rows again would insert the 470 rows that already succeeded a second time and create duplicates. Instead, open the error file, fix the data in the 30 rows using the ERROR column, delete the ERROR column, save as UTF-8 CSV, and run the same insert with only those 30 rows. Then check that 470 + 30 successes equals 500 and that the new error file is empty.
Exercise
An error file contains the line "MALFORMED_ID:Contact ID: id value of incorrect type: 0035g00000AbC:ReportsToId --". What is the likely cause, and where in the workflow did it probably happen?
Show answer
The ReportsToId value is not a valid 15- or 18-character Salesforce ID. Here it is truncated. This usually happens when the ID passes through a spreadsheet that trims or reformats it, or when someone copied it incompletely. Replace it with the full ID from an export, and keep ID columns as text.