Newer Version Available

This content describes an older version of this product. View Latest

Gap Events

Change Data Capture tracks record operations that are part of transactions in Salesforce application servers by generating change events. However, some operations are applied directly in the database, outside of a transaction in the Salesforce application servers. For example, archiving of activities or a data cleanup job in the database. To not miss these operations, gap events are generated to notify you about those changes.

A gap event contains information about the change in the header, such as the change type and record ID, but doesn’t include details about the change, such as record fields. Valid change type values are:

  • GAP_CREATE
  • GAP_UPDATE
  • GAP_DELETE
  • GAP_UNDELETE

Upon receiving a gap event message, your application can retrieve the Salesforce record using the record ID value to get the current data for your system. You can get the Salesforce record with a SOAP API retrieve() call or through a SOQL query.

If the same type of change occurs on the same Salesforce entity within the same transaction, multiple gap events might be replaced with a single gap event. The IDs of the changed records are included in the recordIds header field.

Example

This sample gap event is for an archived calendar event and contains information about the change in the header. The change type for archiving is GAP_UPDATE. The sequenceNumber field is always set to 1.

1{
2  "data":{
3    "schema":"5GiC-KFwBGmSyDn8mqrXgg",
4    "payload":{
5      "ChangeEventHeader":{
6        "commitNumber":288672011,
7        "commitUser":"005xx000001TT96AAG",
8        "sequenceNumber":1,
9        "entityName":"Event",
10        "changeType":"GAP_UPDATE",
11        "changedFields": [],
12        "changeOrigin":"",
13        "transactionKey":"0Mcxx000000000B",
14        "commitTimestamp":1509502088161,
15        "recordIds":[
16            "00Uxx000000fvRQEAY"  ]
17      }
18    },
19    "event":{
20        "replayId":15
21    }
22  },
23  "channel":"/data/ChangeEvents"
24}