How does Field History Tracking capture audit trails of user modifications for compliance and review?
Answer
Basics: For compliance and troubleshooting you need to know who changed a field and what it was before. You turn on tracking per object and per field; Salesforce then writes history rows automatically on every change after enablement.
How it works:
- Setup > Object Manager > object > Fields & Relationships > Set History Tracking.
- Check Enable (object) and select up to 20 fields (standard or custom), then Save.
- Add the History related list to the page layout (History related list / Account History).
- Each change creates a history record with Field, OldValue, NewValue, CreatedBy and CreatedDate.
- Query it through objects such as
AccountHistory,CaseHistory,OpportunityFieldHistory, orMyObject__Historyfor custom objects.
Advanced / deep dive: Only changes after enablement are captured; creation of a record is logged as a single "Created" entry. Some field types are not trackable or only show that a change occurred, for example long text areas, formula, auto-number and roll-up summary fields. History data does not count against data storage. Field Audit Trail (a Shield add-on) extends retention up to 10 years through a HistoryRetentionPolicy and allows up to 60 tracked fields per object. Standard Field History is not a general audit log: it does not track deletes of records (history disappears with the record), reads, or configuration changes; use Setup Audit Trail (180 days of setup changes), Event Monitoring or Shield Platform Encryption's related tooling for those. Reporting uses "<Object> with History" report types. Data is also available through the API for sync into a warehouse for long-term retention.
Code / config example:
-- Who changed Opportunity Amount in the last 30 days?
SELECT OpportunityId, Field, OldValue, NewValue, CreatedBy.Name, CreatedDate
FROM OpportunityFieldHistory
WHERE Field = 'Amount' AND CreatedDate = LAST_N_DAYS:30
ORDER BY CreatedDate DESC
Hidden gotchas & must-remember points:
- 20 tracked fields per object; Field Audit Trail raises this to 60.
- Retention: 18 months in the UI, 24 months via API.
- History is lost when the record is deleted (and the recycle bin retains data 15 days).
- Changes made before tracking was enabled are not retroactive.
- Long text and rich text changes are noted but old/new values are not stored.
- Users need Read on the field to see its history values.
Best practice: Track only fields that matter for audit, export history regularly if you need longer retention, and consider Field Audit Trail for regulated data.