I am writing a trigger in Change Data Capture (CDC) on an update of an event record (EventChangeEvent). I am getting the updated fields in the EventChangeEvent object record. Problem I am facing is how to tie the update field to the records which was just updated. If I am updating a single records I get the record id by doing header.getRecordIds but when I am updating records in bulk there is no way to tie the updated fields to the actual record id.
Here's the documentation of the message payload of the CDC event:
The change that's depicted in a Change Data Capture event applies to any and all records present in
It's a distinctly different model than with regular Apex triggers, where the sObject's identity is primary. In CDC events, the primary payload is the change data itself, and the header tells you to which records the the change applies.
This behavior is described in Change Event Header Fields: