The Salesforce team in their Developer Guide has explained the reasons for the generation of GAP_OVERFLOW events. The Developer Guide also mentions that these events won't carry any actual record Ids and a Dummy record Id will be sent in these events:

Developer Guide.

My question is about how do we replicate the changes for these events if we don't receive the record Ids in the event? What's Salesforce's preferred strategy to replicate the changes corresponding to these events?

1 Answer 1


This is a very usual scenario, you have to write a little bit of workaround for this.

You know the timestamp of last change before overflow event, use that timestamp to get all the updated and deleted records for the given sObject type.

getUpdated() and getDeleted() are part of Data Replication API which was before CDC, given that CDC has its own set of limitation, you have to come up with a mashup of CDC and DataReplication API.

UPDATE: There might be a workaround possible if you can ditch CDC and use standard platform event.

Instead of CDC, in normal Apex Trigger for Sobject, after insert,update and delete, undelete trigger fire an EVENT with JSON serialized data of field data that has changed with a Platform event with type field as INSERT,UPDATE, DELETE, UNDELETE.

Also as its apex code, it gives you flexibility to change and partially disable in case you doing data load/cleanup activity and you dont care about those irrelevant fields.

  • Thank you for your comments, @pranay. One downside to this is that we won't have the information about the event at the time it was generated. From what I know, the Replication API provides the recordIds that have changed and then we can retrieve the data for those recordIds but it is definitely the current data and not the data at the time the event took place. So, is it safe to assume that Salesforce has not provided any way to retrieve the data at the time the overflow event took place?
    – Raman
    Dec 28, 2019 at 3:07
  • 1
    @Raman as of now there is no way if you use CDC. There might be workaround possible I have updated that to demonstrate. Dec 28, 2019 at 22:24
  • 1
    Thanks, @Pranay. As we'll need to deal with the limitations that are already present in Apex Triggers and also the custom code that'll need to be written in Salesforce for each SObject, I suppose we'll go forward with using a combination of Salesforce CDC and Data Replication API.
    – Raman
    Dec 30, 2019 at 8:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .