ChangeEventHeader Class

Contains header fields of Change Data Capture events.

Namespace

EventBus

ChangeEventHeader Properties

The following are properties for ChangeEventHeader.

changedfields

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.

Signature

public List<String> changedfields {get; set;}

Property Value

Type: List<String>

changeorigin

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.

Signature

public String changeorigin {get; set;}

Property Value

Type: String

The format of the changeOrigin field value is:
com/salesforce/api/<API_Name>/<API_Version>;client=<Client_ID>
  • <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 the changeOrigin field.
Example:
com/salesforce/api/soap/49.0;client=Astro

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:

changetype

The operation that caused the change.

Signature

public String changetype {get; set;}

Property Value

Type: String

Can be one of the following values:

  • CREATE
  • UPDATE
  • DELETE
  • UNDELETE
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.

commitnumber

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.

Signature

public Long commitnumber {get; set;}

Property Value

Type: Long

committimestamp

The date and time when the change occurred, represented as the number of milliseconds since January 1, 1970 00:00:00 GMT.

Signature

public Long committimestamp {get; set;}

Property Value

Type: Long

commituser

The ID of the user that ran the change operation.

Signature

public String commituser {get; set;}

Property Value

Type: String

difffields

Contains the names of fields whose values are sent as a unified diff because they contain large text values.

Signature

public List<String> difffields {get; set;}

Property Value

Type: List<String>

entityname

The API name of the standard or custom object that the change pertains to. For example, Account or MyObject__c.

Signature

public String entityname {get; set;}

Property Value

Type: String

nulledfields

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.

Signature

public List<String> nulledfields {get; set;}

Property Value

Type: List<String>

recordids

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 groups 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.

Signature

public List<String> recordids {get; set;}

Property Value

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*.

sequencenumber

The sequence of the change within a transaction. The sequence number starts from 1.

Signature

public Integer sequencenumber {get; set;}

Property Value

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.

  1. Create an account
  2. Create a contact
  3. Create an opportunity
  4. Update a lead

transactionkey

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.

Signature

public String transactionkey {get; set;}

Property Value

Type: String