Sub topic 3
Linking Records and Running Safer Data Loader Imports
Assume you understand Salesforce objects, fields, CSV files, and basic import operations. This chapter focuses on relationships, result files, performance, and repeatable imports.
Linking records with IDs and external IDs
A Salesforce ID identifies one record in one org. Use the parent record's 15- or 18-character ID in a lookup field such as AccountId.
An external ID is a custom field marked External ID. It stores an identifier from another system, such as CRM-10042. External IDs are safer for repeatable integrations because they remain meaningful outside Salesforce.
flowchart TD
A[Child CSV row] --> B{Relationship key}
B -->|Salesforce ID| C[AccountId]
B -->|External ID| D[Account external ID field]
C --> E[Related Account]
D --> Ecaption: Two ways to connect an imported child record to its parent account alt: A child CSV row uses either a Salesforce ID or an account external ID to find a related account.
In Data Loader's field mapping, map the child lookup field to the parent ID column, or select the parent's external ID field as the relationship key. The external ID must be unique enough to identify one parent. Test relationship mappings with a few rows before loading thousands.
Reading result files
Data Loader creates success and error CSV files. A success file usually contains the source row number and the new or changed Salesforce ID. Keep it as an audit record.
An error file contains the rejected row and an error message. Correct the CSV or Salesforce data, remove rows that already succeeded, and run the failed rows again. Do not blindly rerun the entire file, especially after an insert.
Batch size and Bulk API settings
A batch is a group of rows sent in one request. Smaller batches limit the number of rows affected by one failure and make troubleshooting easier. Larger batches can improve throughput.
Bulk API is designed for larger data volumes. Enable it when the operation and org support it. Use serial processing when records compete for the same parents and produce locking errors. Serial processing is slower but can reduce contention.
> callout note > Performance settings do not replace testing. A fast import can also make a mistaken mapping fail faster.
Safe import practices
- Test in a sandbox or Developer Edition org.
- Export the affected records before update or delete operations.
- Keep the original CSV and result files.
- Validate required fields, IDs, picklist values, and date formats.
- Start with a small sample, then increase the batch size.
- Record the mapping and settings used for each import.
Running Data Loader from the command line
Data Loader can run a saved process repeatedly. Define the process in its configuration files, then run it from the Data Loader bin directory:
# macOS or Linux
./process.sh "AccountInsert"
# Windows
process.bat "AccountInsert"Store credentials securely in Data Loader's encrypted configuration. Do not place passwords in scripts or source control.
Exercise
You need to import contacts whose account names can change. Which relationship key should you prefer?
Show answer
Use a stable, unique external ID on Account rather than matching by account name.