{"id":1632,"date":"2026-09-10T19:00:00","date_gmt":"2026-09-10T13:30:00","guid":{"rendered":"https:\/\/swapnilzambare.com\/blog\/change-data-capture-salesforce-apex\/"},"modified":"2026-09-10T19:00:00","modified_gmt":"2026-09-10T13:30:00","slug":"change-data-capture-salesforce-apex","status":"publish","type":"post","link":"https:\/\/swapnilzambare.com\/blog\/change-data-capture-salesforce-apex\/","title":{"rendered":"Change Data Capture in Salesforce with Apex Triggers"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Change Data Capture is a Salesforce feature that publishes an event every time a record is created, updated, deleted or undeleted. You do not write any publishing code. You choose the objects, and Salesforce sends change events that other systems or Apex triggers can process after the save commits.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In this post, you will learn how to turn on Change Data Capture, what a change event contains, how to read the ChangeEventHeader, and how to write an Apex change event trigger. It builds on <a href=\"https:\/\/swapnilzambare.com\/blog\/salesforce-platform-events-apex\/\">Salesforce Platform Events in Apex<\/a>, <a href=\"https:\/\/swapnilzambare.com\/blog\/asynchronous-apex-overview\/\">Asynchronous Apex<\/a> and <a href=\"https:\/\/swapnilzambare.com\/blog\/apex-trigger-basics-context-variables\/\">Apex trigger basics<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What is Change Data Capture?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Change Data Capture (CDC) is a built-in stream of change events for the objects you select. Each change event has a header that describes the change, plus the field values that changed. For example, when a course fee changes, Salesforce publishes a Course__ChangeEvent with Fee__c and its new value.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Think of a bank sending you an SMS for every transaction. You do not ask the bank each hour whether something changed. The bank tells you the moment money moves, with the amount and the time. Change events are those SMS alerts for your records.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Why Change Data Capture Matters<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Keeping systems in sync by polling is slow and wasteful. Here is why Change Data Capture matters at Bright Path Tutors.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>First, the public website must show new course fees within seconds.<\/li>\n\n<li>Also, the finance system needs every enrolment change, including deletes.<\/li>\n\n<li>Next, an audit log of fee changes should not slow down the course save.<\/li>\n\n<li>No custom publishing code is needed for each object.<\/li>\n\n<li>Finally, events include only changed fields, so payloads stay small.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">So CDC gives near real-time sync with very little code.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How Change Data Capture Works<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Change Data Capture follows a steady flow. First, an admin selects objects in Setup &gt; Integrations &gt; Change Data Capture. Next, a user or process creates, updates, deletes or undeletes a record of that object. Then, after the transaction commits, Salesforce publishes a change event on the event bus. After that, subscribers receive it: Apex change event triggers, flows or outside systems through the Pub\/Sub API. Finally, each subscriber reads the header and changed fields, and acts on them.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"640\" src=\"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/change-data-capture-salesforce-apex-diagram-1-1024x640.png\" alt=\"Change Data Capture diagram showing select, change, commit, publish, subscribe and act\" class=\"wp-image-1630\" srcset=\"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/change-data-capture-salesforce-apex-diagram-1-1024x640.png 1024w, https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/change-data-capture-salesforce-apex-diagram-1-300x188.png 300w, https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/change-data-capture-salesforce-apex-diagram-1-768x480.png 768w, https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/change-data-capture-salesforce-apex-diagram-1-1536x960.png 1536w, https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/change-data-capture-salesforce-apex-diagram-1-2048x1280.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">How a record change becomes a change event.<\/figcaption><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Selecting Objects<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">You select standard and custom objects in Setup. By default, you can select up to five objects across all channels, and add-ons raise this allocation.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Change Event Names<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Each object has its own change event. Standard objects use names such as AccountChangeEvent. Custom objects use names such as Course__ChangeEvent.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">The ChangeEventHeader<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Every change event has a ChangeEventHeader. It includes entityName, recordIds, changeType, changedFields, commitTimestamp, commitUser and transactionKey.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Change Types<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">changeType is CREATE, UPDATE, DELETE or UNDELETE. Gap and overflow types, such as GAP_UPDATE or GAP_OVERFLOW, mean Salesforce could not send full details, so subscribers should re-read the record.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Apex Change Event Triggers<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">An Apex trigger on a change event object supports only after insert. It runs asynchronously after the original transaction commits, by default as the Automated Process user.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">ChangeEventHeader Fields<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The table below lists the header fields you will use most.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Field<\/th><th>What it tells you<\/th><\/tr><\/thead><tbody><tr><td>entityName<\/td><td>The object, such as Course__c<\/td><\/tr><tr><td>recordIds<\/td><td>The Ids of changed records<\/td><\/tr><tr><td>changeType<\/td><td>CREATE, UPDATE, DELETE or UNDELETE<\/td><\/tr><tr><td>changedFields<\/td><td>Fields that changed in an update<\/td><\/tr><tr><td>commitUser<\/td><td>The user who made the change<\/td><\/tr><tr><td>commitTimestamp<\/td><td>When the change was committed<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Change Data Capture vs Platform Events<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The table below compares CDC with custom platform events.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Feature<\/th><th>Change Data Capture<\/th><th>Platform events<\/th><\/tr><\/thead><tbody><tr><td>Who publishes<\/td><td>Salesforce, automatically<\/td><td>Your code or an outside system<\/td><\/tr><tr><td>Event shape<\/td><td>Fixed, based on the object<\/td><td>You design the fields<\/td><\/tr><tr><td>Trigger<\/td><td>Every record change<\/td><td>Business moments you choose<\/td><\/tr><tr><td>Setup<\/td><td>Select objects<\/td><td>Define event and publish code<\/td><\/tr><tr><td>Best for<\/td><td>Data sync and audit<\/td><td>Business processes and messages<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">When to use which is clear. Use Change Data Capture to sync or audit record changes. Use platform events when you want to send a business message, such as &#8220;payment received&#8221;.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"640\" src=\"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/change-data-capture-salesforce-apex-diagram-2-1024x640.png\" alt=\"Change Data Capture diagram comparing Change Data Capture and platform events\" class=\"wp-image-1631\" srcset=\"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/change-data-capture-salesforce-apex-diagram-2-1024x640.png 1024w, https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/change-data-capture-salesforce-apex-diagram-2-300x188.png 300w, https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/change-data-capture-salesforce-apex-diagram-2-768x480.png 768w, https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/change-data-capture-salesforce-apex-diagram-2-1536x960.png 1536w, https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/change-data-capture-salesforce-apex-diagram-2-2048x1280.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">Change Data Capture vs platform events.<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">A Real Change Data Capture Example<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Let&#8217;s use Change Data Capture at Bright Path Tutors to log every course fee change, without adding work to the course save.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 1: Turn On CDC for Course<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Go to Setup &gt; Integrations &gt; Change Data Capture.<\/li>\n\n<li>Move Course (Course__c) from Available Entities to Selected Entities.<\/li>\n\n<li>Click Save.<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">From now on, Salesforce publishes a Course__ChangeEvent after each committed change to a course.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 2: Write the Change Event Trigger<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>trigger CourseChangeTrigger on Course__ChangeEvent (after insert) {\n\n    List&lt;Fee_Change_Log__c&gt; logs = new List&lt;Fee_Change_Log__c&gt;();\n\n    for (Course__ChangeEvent evt : Trigger.new) {\n        EventBus.ChangeEventHeader header = evt.ChangeEventHeader;\n        if (header.changeType == 'UPDATE' &amp;&amp; header.changedFields.contains('Fee__c')) {\n            for (String recordId : header.recordIds) {\n                logs.add(new Fee_Change_Log__c(\n                    Course__c = recordId,\n                    New_Fee__c = evt.Fee__c,\n                    Changed_By__c = header.commitUser));\n            }\n        }\n    }\n    Database.insert(logs, false, AccessLevel.SYSTEM_MODE);\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The trigger checks each event&#8217;s header. If it is an update that changed Fee__c, it writes one log per record Id. One event can cover several records changed in the same way, which is why the code loops over recordIds.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 3: Check the Log<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Here is what the trigger writes after a manager changes the Apex Basics fee to 5,500.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Fee_Change_Log__c: Course = Apex Basics, New_Fee = 5500, Changed_By = 005...Asha<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The course save stayed fast, because the log was written later by the change event trigger.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Testing Change Data Capture<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">In a test, call Test.enableChangeDataCapture() first, then change records. Change events are delivered at Test.stopTest, or when you call Test.getEventBus().deliver(). Then assert the records your trigger created.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Common Mistakes with Change Data Capture<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Expecting change event triggers to run before the original save commits.<\/li>\n\n<li>Reading only recordIds[0] when one event can hold several records.<\/li>\n\n<li>Ignoring gap and overflow change types.<\/li>\n\n<li>Selecting many objects without checking allocations.<\/li>\n\n<li>Forgetting that unchanged fields are null in update events.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Best Practices for Change Data Capture<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Select only objects that other systems truly need.<\/li>\n\n<li>Check changeType and changedFields before acting.<\/li>\n\n<li>Loop over every Id in recordIds.<\/li>\n\n<li>Re-query the record when you get a gap or overflow event.<\/li>\n\n<li>Keep change event triggers bulk-safe and idempotent.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Practice Task<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Extend the trigger to also log deleted courses. Hint: check for changeType DELETE, and remember that field values are not sent for deletes, so log only the record Id and the user.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Most Asked Interview Questions on Change Data Capture<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">CDC questions show up in integration and architect interviews. Here are the 21 questions asked most about Change Data Capture.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Basic Questions on Change Data Capture<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q1: What is Change Data Capture?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A Salesforce feature that publishes events for record creates, updates, deletes and undeletes.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q2: How do you turn it on for an object?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Select the object in Setup &gt; Integrations &gt; Change Data Capture.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q3: What is the change event name for a custom object?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The object name with ChangeEvent, such as Course__ChangeEvent.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q4: What does the ChangeEventHeader contain?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Details such as entityName, recordIds, changeType, changedFields, commitUser and commitTimestamp.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q5: Which change types exist?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">CREATE, UPDATE, DELETE and UNDELETE, plus gap and overflow types.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q6: Who can subscribe to change events?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Apex change event triggers, flows and outside systems through the Pub\/Sub API.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q7: How many objects can you select by default?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Up to five, across all channels.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Code and Scenario Questions on Change Data Capture<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q8: Which trigger event does a change event trigger support?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Only after insert.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q9: When does a change event trigger run?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Asynchronously, after the original transaction commits.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q10: How do you know which fields changed?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Read changedFields in the ChangeEventHeader.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q11: Why loop over recordIds?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">One change event can represent several records changed in the same transaction.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q12: What values do unchanged fields have in an update event?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">They are null, because only changed fields are sent.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q13: How do you test a change event trigger?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Call Test.enableChangeDataCapture(), change records, then deliver events with stopTest or Test.getEventBus().deliver().<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q14: Which user runs change event triggers by default?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The Automated Process user.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Advanced Questions on Change Data Capture<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q15: What does a gap event mean?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Salesforce could not send full change details, so subscribers should re-read the record.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q16: What does GAP_OVERFLOW mean?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Too many changes happened in one transaction to send individual events.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q17: How do you group changes from one transaction?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Use transactionKey and sequenceNumber from the header.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q18: Why use CDC instead of an after trigger for audit logs?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It moves the work out of the user&#8217;s save, keeping saves fast.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q19: How do outside systems subscribe?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Through the Pub\/Sub API, using a channel such as \/data\/ChangeEvents or an object-specific channel.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q20: What is changeOrigin used for?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It tells subscribers which client or API made the change, so they can skip their own updates.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q21: How do you avoid sync loops between two systems?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Ignore changes that your integration user made, using commitUser or changeOrigin.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Official Resources<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/developer.salesforce.com\/docs\/platform\/change-data-capture\/guide\/cdc-intro.html\" target=\"_blank\" rel=\"noopener noreferrer\">Change Data Capture Developer Guide<\/a><\/li>\n\n<li><a href=\"https:\/\/developer.salesforce.com\/docs\/platform\/change-data-capture\/guide\/cdc-select-objects.html\" target=\"_blank\" rel=\"noopener noreferrer\">Select Objects for Change Notifications in the User Interface<\/a><\/li>\n\n<li><a href=\"https:\/\/trailhead.salesforce.com\/content\/learn\/modules\/change-data-capture\" target=\"_blank\" rel=\"noopener noreferrer\">Change Data Capture Basics (Trailhead)<\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Quick Recap<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Change Data Capture publishes events for record changes automatically.<\/li>\n\n<li>Select objects in Setup, up to five by default.<\/li>\n\n<li>The ChangeEventHeader holds changeType, recordIds and changedFields.<\/li>\n\n<li>Change event triggers run after commit and support only after insert.<\/li>\n\n<li>Use CDC for sync and audit, and platform events for business messages.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">What&#8217;s Next?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">You now know every async tool. Next, read our guide on <a href=\"https:\/\/swapnilzambare.com\/blog\/async-apex-types-which-to-use\/\">which async Apex type to use<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Change Data Capture is a Salesforce feature that publishes an event every time a record is created, updated, deleted or undeleted. You do not&hellip;<\/p>\n","protected":false},"author":1,"featured_media":1629,"comment_status":"","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_swapz_level":"","_swapz_series_part":0,"_swapz_hide_toc":false,"_swapz_hide_featured":false,"_swapz_description":"","footnotes":""},"categories":[8,96],"tags":[68,98,112,81,91,7,97],"swapz_series":[],"class_list":["post-1632","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-salesforce","category-salesforce-developer","tag-advanced","tag-apex","tag-async-apex","tag-integration","tag-interview-questions","tag-salesforce","tag-salesforce-developer"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Change Data Capture in Salesforce with Apex<\/title>\n<meta name=\"description\" content=\"Change Data Capture explained simply: selecting objects, change events, ChangeEventHeader, changedFields, Apex change triggers and 21 interview Q&amp;A.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/swapnilzambare.com\/blog\/change-data-capture-salesforce-apex\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Change Data Capture in Salesforce with Apex\" \/>\n<meta property=\"og:description\" content=\"Change Data Capture explained simply: selecting objects, change events, ChangeEventHeader, changedFields, Apex change triggers and 21 interview Q&amp;A.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/swapnilzambare.com\/blog\/change-data-capture-salesforce-apex\/\" \/>\n<meta property=\"og:site_name\" content=\"Swapnil Zambare - Blog\" \/>\n<meta property=\"article:published_time\" content=\"2026-09-10T13:30:00+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/change-data-capture-salesforce-apex-featured.png\" \/>\n\t<meta property=\"og:image:width\" content=\"2400\" \/>\n\t<meta property=\"og:image:height\" content=\"1260\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Swapnil Zambare\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Swapnil Zambare\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/change-data-capture-salesforce-apex\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/change-data-capture-salesforce-apex\\\/\"},\"author\":{\"name\":\"Swapnil Zambare\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#\\\/schema\\\/person\\\/922ac0131aaa7088c78c2cb1700e0c9a\"},\"headline\":\"Change Data Capture in Salesforce with Apex Triggers\",\"datePublished\":\"2026-09-10T13:30:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/change-data-capture-salesforce-apex\\\/\"},\"wordCount\":1519,\"publisher\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/change-data-capture-salesforce-apex\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/change-data-capture-salesforce-apex-featured.png\",\"keywords\":[\"Advanced\",\"Apex\",\"Async Apex\",\"Integration\",\"Interview Questions\",\"Salesforce\",\"Salesforce Developer\"],\"articleSection\":[\"Salesforce\",\"Salesforce Developer\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/change-data-capture-salesforce-apex\\\/\",\"url\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/change-data-capture-salesforce-apex\\\/\",\"name\":\"Change Data Capture in Salesforce with Apex\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/change-data-capture-salesforce-apex\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/change-data-capture-salesforce-apex\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/change-data-capture-salesforce-apex-featured.png\",\"datePublished\":\"2026-09-10T13:30:00+00:00\",\"description\":\"Change Data Capture explained simply: selecting objects, change events, ChangeEventHeader, changedFields, Apex change triggers and 21 interview Q&A.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/change-data-capture-salesforce-apex\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/change-data-capture-salesforce-apex\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/change-data-capture-salesforce-apex\\\/#primaryimage\",\"url\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/change-data-capture-salesforce-apex-featured.png\",\"contentUrl\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/change-data-capture-salesforce-apex-featured.png\",\"width\":2400,\"height\":1260,\"caption\":\"Change Data Capture featured image: title card with an Apex code example\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/change-data-capture-salesforce-apex\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Change Data Capture in Salesforce with Apex Triggers\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/\",\"name\":\"Swapnil Zambare - Blog\",\"description\":\"Salesforce &amp; Tech Guides\",\"publisher\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#organization\",\"name\":\"Swapnil Zambare - Blog\",\"url\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/09\\\/site-icon-512.png\",\"contentUrl\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/09\\\/site-icon-512.png\",\"width\":512,\"height\":512,\"caption\":\"Swapnil Zambare - Blog\"},\"image\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.linkedin.com\\\/in\\\/theSwapnilZambare\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#\\\/schema\\\/person\\\/922ac0131aaa7088c78c2cb1700e0c9a\",\"name\":\"Swapnil Zambare\",\"sameAs\":[\"https:\\\/\\\/swapnilzambare.com\\\/blog\"],\"url\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/author\\\/swapnil-zambare\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Change Data Capture in Salesforce with Apex","description":"Change Data Capture explained simply: selecting objects, change events, ChangeEventHeader, changedFields, Apex change triggers and 21 interview Q&A.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/swapnilzambare.com\/blog\/change-data-capture-salesforce-apex\/","og_locale":"en_US","og_type":"article","og_title":"Change Data Capture in Salesforce with Apex","og_description":"Change Data Capture explained simply: selecting objects, change events, ChangeEventHeader, changedFields, Apex change triggers and 21 interview Q&A.","og_url":"https:\/\/swapnilzambare.com\/blog\/change-data-capture-salesforce-apex\/","og_site_name":"Swapnil Zambare - Blog","article_published_time":"2026-09-10T13:30:00+00:00","og_image":[{"width":2400,"height":1260,"url":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/change-data-capture-salesforce-apex-featured.png","type":"image\/png"}],"author":"Swapnil Zambare","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Swapnil Zambare","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/swapnilzambare.com\/blog\/change-data-capture-salesforce-apex\/#article","isPartOf":{"@id":"https:\/\/swapnilzambare.com\/blog\/change-data-capture-salesforce-apex\/"},"author":{"name":"Swapnil Zambare","@id":"https:\/\/swapnilzambare.com\/blog\/#\/schema\/person\/922ac0131aaa7088c78c2cb1700e0c9a"},"headline":"Change Data Capture in Salesforce with Apex Triggers","datePublished":"2026-09-10T13:30:00+00:00","mainEntityOfPage":{"@id":"https:\/\/swapnilzambare.com\/blog\/change-data-capture-salesforce-apex\/"},"wordCount":1519,"publisher":{"@id":"https:\/\/swapnilzambare.com\/blog\/#organization"},"image":{"@id":"https:\/\/swapnilzambare.com\/blog\/change-data-capture-salesforce-apex\/#primaryimage"},"thumbnailUrl":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/change-data-capture-salesforce-apex-featured.png","keywords":["Advanced","Apex","Async Apex","Integration","Interview Questions","Salesforce","Salesforce Developer"],"articleSection":["Salesforce","Salesforce Developer"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/swapnilzambare.com\/blog\/change-data-capture-salesforce-apex\/","url":"https:\/\/swapnilzambare.com\/blog\/change-data-capture-salesforce-apex\/","name":"Change Data Capture in Salesforce with Apex","isPartOf":{"@id":"https:\/\/swapnilzambare.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/swapnilzambare.com\/blog\/change-data-capture-salesforce-apex\/#primaryimage"},"image":{"@id":"https:\/\/swapnilzambare.com\/blog\/change-data-capture-salesforce-apex\/#primaryimage"},"thumbnailUrl":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/change-data-capture-salesforce-apex-featured.png","datePublished":"2026-09-10T13:30:00+00:00","description":"Change Data Capture explained simply: selecting objects, change events, ChangeEventHeader, changedFields, Apex change triggers and 21 interview Q&A.","breadcrumb":{"@id":"https:\/\/swapnilzambare.com\/blog\/change-data-capture-salesforce-apex\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/swapnilzambare.com\/blog\/change-data-capture-salesforce-apex\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/swapnilzambare.com\/blog\/change-data-capture-salesforce-apex\/#primaryimage","url":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/change-data-capture-salesforce-apex-featured.png","contentUrl":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/change-data-capture-salesforce-apex-featured.png","width":2400,"height":1260,"caption":"Change Data Capture featured image: title card with an Apex code example"},{"@type":"BreadcrumbList","@id":"https:\/\/swapnilzambare.com\/blog\/change-data-capture-salesforce-apex\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/swapnilzambare.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Change Data Capture in Salesforce with Apex Triggers"}]},{"@type":"WebSite","@id":"https:\/\/swapnilzambare.com\/blog\/#website","url":"https:\/\/swapnilzambare.com\/blog\/","name":"Swapnil Zambare - Blog","description":"Salesforce &amp; Tech Guides","publisher":{"@id":"https:\/\/swapnilzambare.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/swapnilzambare.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/swapnilzambare.com\/blog\/#organization","name":"Swapnil Zambare - Blog","url":"https:\/\/swapnilzambare.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/swapnilzambare.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/09\/site-icon-512.png","contentUrl":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/09\/site-icon-512.png","width":512,"height":512,"caption":"Swapnil Zambare - Blog"},"image":{"@id":"https:\/\/swapnilzambare.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.linkedin.com\/in\/theSwapnilZambare"]},{"@type":"Person","@id":"https:\/\/swapnilzambare.com\/blog\/#\/schema\/person\/922ac0131aaa7088c78c2cb1700e0c9a","name":"Swapnil Zambare","sameAs":["https:\/\/swapnilzambare.com\/blog"],"url":"https:\/\/swapnilzambare.com\/blog\/author\/swapnil-zambare\/"}]}},"_links":{"self":[{"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/posts\/1632","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/comments?post=1632"}],"version-history":[{"count":0,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/posts\/1632\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/media\/1629"}],"wp:attachment":[{"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/media?parent=1632"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/categories?post=1632"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/tags?post=1632"},{"taxonomy":"swapz_series","embeddable":true,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/swapz_series?post=1632"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}