Restoring System Timestamps in Salesforce
By default, CreatedDate and SystemModStamp are read-only system fields. During a standard restoration via Data Loader or the Bulk API, Salesforce ignores any values provided for these fields in a CSV and instead populates them with the timestamp of the restoration activity.
To preserve original timestamps during a data restoration, you must use the "Enable Set Audit Fields upon Record Creation" permission.
Implementation Steps
This permission allows the API to populate CreatedDate, CreatedById, LastModifiedDate, and LastModifiedById during the initial record insertion.
- Enable the Permission: In Setup, search the Quick Find box for "Set Audit Fields" and enable the organization setting (the exact menu path varies by Salesforce release).
- Assign to User: Ensure the user performing the import has this permission assigned via their Profile or a Permission Set.
- Map the CSV: In Data Loader or your Bulk API tool, map the original date columns from your export file to the
CreatedDate and LastModifiedDate fields.
- Execute Insert: Perform the import. The system will now accept the dates provided in the CSV for new records.
- Revoke Permission: Immediately remove the permission from the user or disable it globally to maintain the integrity of your audit trail for future organic records.
Technical Constraints and Assumptions
There are critical limitations to this method that affect how SystemModStamp behaves:
- Insert Only: This permission only applies to the initial creation of a record. You cannot use it to backdate the
LastModifiedDate or SystemModStamp of an existing record via an Update operation.
- SystemModStamp Behavior: While
LastModifiedDate can be set, SystemModStamp is a system-level timestamp used for replication and synchronization. In many org configurations it will still reflect the actual time the record was committed to the database, regardless of the LastModifiedDate provided. Treat this as likely rather than guaranteed and confirm in your org.
- Trigger Interference: If your org has active Apex triggers or Flows that update the record immediately upon insertion, the
SystemModStamp will be updated to the time those processes executed.
Verification Process
Before performing a full restoration, verify the behavior with a scoped test:
-- 1. Insert a single record via Data Loader with a custom CreatedDate.
-- 2. Run a SOQL query to verify the result:
SELECT Id, CreatedDate, LastModifiedDate, SystemModStamp
FROM Account
WHERE Id = 'your_test_id'
If the imported CreatedDate is rejected, the permission is not active for the importing user. If SystemModStamp shows the insert time rather than the imported value, that is expected system behavior and not a misconfiguration.
Diagnostic Detail Needed: Are you performing a full object restoration (Insert) or attempting to synchronize timestamps for records that already exist in the destination org (Update)? The audit-field method only works for inserts, so the answer changes if records already exist.