ChangeEventHeader Class
Contains header fields of Change Data Capture events.
See Also
The following are properties for ChangeEventHeader.
-
A list of the fields that were changed in an update operation, including the
LastModifiedDatesystem field. This field is empty for other operations, including record creation. This property is available in Apex saved using API version 47.0 or later. -
Only populated for changes done by API apps or from Lightning Experience; empty otherwise. The Salesforce API and the API client ID that initiated the change, if set by the client. Use this field to detect whether your app initiated the change to not process the change again and potentially avoid a deep cycle of changes.
-
The operation that caused the change.
-
The system change number (SCN) of a committed transaction, which increases sequentially. This field is provided for diagnostic purposes. The field value is not guaranteed to be unique in Salesforce—it is unique only in a single database instance. If your Salesforce org migrates to another database instance, the commit number might not be unique or sequential.
-
The date and time when the change occurred, represented as the number of milliseconds since January 1, 1970 00:00:00 GMT.
-
The ID of the user that ran the change operation.
-
Contains the names of fields whose values are sent as a unified diff because they contain large text values.
-
The API name of the standard or custom object that the change pertains to. For example, Account or MyObject__c.
-
Contains the names of fields whose values were changed to null in an update operation. Use this field in Apex change event messages to determine if a field was changed to null in an update and isn’t an unchanged field.
-
One or more record IDs for the changed records. Typically, this field contains one record ID. If in one transaction the same change occurred in multiple records of the same object type during one second, Salesforce merges the change notifications. In this case, Salesforce sends one change event for all affected records and the
recordIdsfield contains the IDs for all records that have the same change. -
The sequence of the change within a transaction. The sequence number starts from 1.
-
A string that uniquely identifies each Salesforce transaction. You can use this key to identify and group all changes that were made in the same transaction.
A list of the fields that were changed in an update operation, including the LastModifiedDate system field. This field is empty for other operations, including record creation. This property is available in Apex saved using API version 47.0 or later.
public List<String> changedfields {get; set;}
Type: List<String>
Only populated for changes done by API apps or from Lightning Experience; empty otherwise. The Salesforce API and the API client ID that initiated the change, if set by the client. Use this field to detect whether your app initiated the change to not process the change again and potentially avoid a deep cycle of changes.
public String changeorigin {get; set;}
Type: String
The format of the changeOrigin field value is:
<API_Name>is the name of the Salesforce API used to make the data change. It can take one of these values: soap, rest, bulkapi, xmlrpc, oldsoap, toolingsoap, toolingrest, apex, apexdebuggerrest.<API_Version>is the version of the API call that made the change and is in the format XX.X.<Client_ID>is a string that contains the client ID of the app that initiated the change. If the client ID is not set in the API call,client=<Client_ID>is not appended to thechangeOriginfield.
Example:
The client ID is set in the Call Options header of an API call. For an example on how to set the Call Options header, see:
- REST API: Sforce-Call-Options Header. (Bulk API also uses the Sforce-Call-Options header. )
- SOAP API: CallOptions Header. (Apex API also uses the CallOptions element.)
The operation that caused the change.
public String changetype {get; set;}
Type: String
Can be one of the following values:
- CREATE
- UPDATE
- DELETE
- UNDELETE
- SNAPSHOT (reserved for future use)
For gap events, the change type starts with the GAP_ prefix.
- GAP_CREATE
- GAP_UPDATE
- GAP_DELETE
- GAP_UNDELETE
For overflow events, the change type is GAP_OVERFLOW.
The system change number (SCN) of a committed transaction, which increases sequentially. This field is provided for diagnostic purposes. The field value is not guaranteed to be unique in Salesforce—it is unique only in a single database instance. If your Salesforce org migrates to another database instance, the commit number might not be unique or sequential.
public Long commitnumber {get; set;}
Type: Long
The date and time when the change occurred, represented as the number of milliseconds since January 1, 1970 00:00:00 GMT.
public Long committimestamp {get; set;}
Type: Long
The ID of the user that ran the change operation.
public String commituser {get; set;}
Type: String
Contains the names of fields whose values are sent as a unified diff because they contain large text values.
public List<String> difffields {get; set;}
Type: List<String>
See Also
The API name of the standard or custom object that the change pertains to. For example, Account or MyObject__c.
public String entityname {get; set;}
Type: String
Contains the names of fields whose values were changed to null in an update operation. Use this field in Apex change event messages to determine if a field was changed to null in an update and isn’t an unchanged field.
public List<String> nulledfields {get; set;}
Type: List<String>
One or more record IDs for the changed records. Typically, this field contains one record ID. If in one transaction the same change occurred in multiple records of the same object type during one second, Salesforce merges the change notifications. In this case, Salesforce sends one change event for all affected records and the recordIds field contains the IDs for all records that have the same change.
public List<String> recordids {get; set;}
Type: List<String>
Examples of operations with same changes are:
- Update of fieldA to valueA in Account records.
- Deletion of Account records.
- Renaming or replacing a picklist value that results in updating the field value in all affected records.
The recordIds field can contain a wildcard value when a change event message is generated for custom field type conversions that cause data loss. In this case, the recordIds value is the three-character prefix of the object, followed by the wildcard character *. For example, for accounts, the value is 001*.
The sequence of the change within a transaction. The sequence number starts from 1.
public Integer sequencenumber {get; set;}
Type: Integer
A lead conversion is an example of a transaction that can have multiple changes. A lead conversion results in the following sequence of changes, all within the same transaction.
- Create an account
- Create a contact
- Create an opportunity
- Update a lead
A string that uniquely identifies each Salesforce transaction. You can use this key to identify and group all changes that were made in the same transaction.
public String transactionkey {get; set;}
Type: String