Understanding Change Data Capture (CDC) in Salesforce
In a world where real-time data is king, businesses need to keep their systems synchronized and updated instantly. Salesforce’s Change Data Capture (CDC) is a powerful feature that makes this possible by letting you track changes to Salesforce records in real-time.
Whether you’re integrating Salesforce with external systems or building custom event-driven apps, CDC ensures that you’re always working with the latest data — without running expensive queries or polling the database.
What is Change Data Capture?
Change Data Capture in Salesforce is a streaming event mechanism that lets you capture changes (inserts, updates, deletes, undeletes) made to Salesforce records.
Whenever a record changes, Salesforce sends out a change event, which can be consumed by external systems (like Heroku, AWS, external APIs) or internal processes (like Apex triggers or Platform Events).
Key Benefits of CDC
- Real-time Data Sync
Instantly push changes to downstream systems without delay.
- Reduced API Calls
No need to continuously poll the system — changes are pushed automatically.
- Simplified Integration
Perfect for integrating Salesforce with data lakes, ERPs, or custom apps.
- Track Field-Level Changes
Know exactly what changed, and when.
How Does CDC Work?
- You enable CDC for specific objects (like Account, Contact, Custom Objects).
- Salesforce automatically creates a Change Event object for each one.
- Whenever records are created, updated, deleted, or undeleted, a change event is fired.
- Consumers (like Apex, External Services, etc.) subscribe to the event and process it.
Use Cases for CDC
- 🔄 Sync Salesforce data with external systems (e.g., SAP, Oracle, Snowflake)
- 🛎️ Trigger real-time notifications when a record changes
- 📦 Keep external caches or warehouses updated
- 🧠 Feed ML models or analytics platforms with fresh data
Example Scenario
Suppose you enable CDC for the Account object. When a new account is created:
- A change event like AccountChangeEvent is published.
- It contains info such as:
- Changed fields
- Old and new values
- Change type (CREATE, UPDATE, DELETE)
- Who made the change
You can subscribe to this event using:
- Apex triggers
- CometD clients (Java, Node.js, etc.)
- External platforms (via Salesforce Event Bus)
Enabling CDC in Salesforce
- Go to Setup > Change Data Capture
- Select the objects you want to track
- Click Enable
- You’ll now see corresponding ObjectChangeEvent objects
Sample CDC Event Structure
json
{
“changeType”: “UPDATE”,
“entityName”: “Account”,
“recordIds”: [“001XXXXXXXXXXXX”],
“changedFields”: [“Phone”, “Rating”],
“changeOrigin”: “com/salesforce/api”,
“transactionKey”: “00000000-0000-0000-0000-000000000000”
}
📎 Tools to Consume CDC
- Apex Triggers on Change Events
- Platform Event Subscribers
- Salesforce Connect
- External Systems using CometD/Bayeux protocol
Things to Know
- CDC is governed by event streaming limits.
- Retention period for events is 3 days (72 hours).
- Not every field is supported — some are excluded (like formula or calculated fields).
- You can filter and route change events based on Channel.
Final Thoughts
Change Data Capture is a game-changer for real-time integrations and automation in Salesforce. It’s especially useful for complex architectures where syncing data across platforms is crucial.
If your org needs instant updates, efficient sync, and minimal API usage, CDC should be in your toolbox.