Salesforce Decode
Salesforcedecode
Back to questions
IntegrationIntermediatecdcfilteringchangedfields

Filter CDC ChangeEventHeader changedFields in Apex and middleware subscribers

Real World Scenario

Subscriber processes every Account CDC event but only BillingCity changes matter; CPU cost triples processing irrelevant field updates.

Expected Answer

• Parse ChangeEventHeader changedFields array before business logic • Early return if intersection with watch list empty • changedFields includes compound address subfields explicitly • Create events omit changedFields null handle separately • Delete events process regardless changedFields • Unit test filter with mock ChangeEvent payload • Combine with Salesforce CDC field selection at source

Follow-Up Questions & Answers

Click to expand — each follow-up includes a direct, interview-ready answer

Direct answer: Parse ChangeEventHeader changedFields array before business logic Also consider: Early return if intersection with watch list empty In practice: changedFields includes compound address subfields explicitly Balance speed of delivery with maintainability.

Architect Perspective

changedFields filter is cheap subscriber optimization—apply before any external callout.