Salesforce Change Data Capture
1. Overview
Salesforce is a cloud-based CRM software designed for service, marketing, and sales.
Salesforce Change Data Capture publishes a change event every time a record of an enabled object is created, updated, deleted or undeleted. Cinchy subscribes to those events and applies each one to the target table of your data sync.
The Salesforce Change Data Capture source supports real-time syncs.
Before you configure the sync, enable the object for Change Data Capture in Salesforce and grant the integration user permission to read every record of the object. The full list of prerequisites and listener behaviours is on the Salesforce Change Data Capture real-time source page.
Info tab
You can find the parameters in the Info tab below (Image 1).
Values
| Parameter | Description | Example |
|---|---|---|
| Title | Mandatory. Input a name for your data sync | to Cinchy |
| Description | Optional. Add in a description for your sync. There is a 500 character limit in this field. | |
| Variables | Optional. Review our documentation on Variables herefor more information about this field. | |
| Permissions | Data syncs are role based access systems where you can give specific groups read, write, execute, and/or all of the above with admin access. Inputting at least an Admin Group is mandatory. |
Source tab
The following table outlines the mandatory and optional parameters you will find on the Source tab.
- Source Details
- Listener Configuration
- Schema
- Filter
The following parameters will help to define your data sync source and how it functions.
| Parameter | Description | Example |
|---|---|---|
| Source | Mandatory. Select your source from the drop-down menu. | Salesforce Change Data Capture |
To set up a real-time sync, you must configure your Listener values. You can do so through the Connections UI.
Note that if there is more than one listener associated with your data sync, you will need to configure the additional listeners via the Listener Configuration table.
Reset behaviour
| Parameter | Description | Example |
|---|---|---|
| Auto Offset Reset | Earliest, Latest, or None. When the listener has no recorded replay ID, or the recorded one has aged out of Salesforce's 72-hour retention window, this setting decides where to start reading. Earliest: Reads every retained change event, then new events. Latest: Reads new events only. Typical configuration. None: The listener does not start. | Latest |
Topic JSON
The below table can be used to help create your Topic JSON needed to set up a real-time sync.
| Parameter | Description | Example |
|---|---|---|
name | Mandatory. The API name of the change event: the object name followed by ChangeEvent. For a custom object Salesforce drops the c of __c, so Employee__c becomes Employee__ChangeEvent. | AccountChangeEvent |
channel | Optional. Defaults to /data/{name}. Set /data/{ChannelName}__chn to subscribe through a custom channel. /data/ChangeEvents is not accepted. | /data/SalesEvents__chn |
entityName | Optional. The object this listener syncs. Defaults to the object behind name. On a custom channel, events for other objects are skipped. | Account |
fields | Optional. The record fields read back from Salesforce for each event. Empty reads every field. If set, it must include Id and every column in the source schema. | ["Id", "Name", "Industry"] |
Example Topic JSON
{
"name": "AccountChangeEvent",
"channel": "/data/AccountChangeEvent",
"entityName": "Account",
"fields": []
}
Connection attributes
The Connection Attributes JSON is the same as for the Salesforce Platform Event source. Use the client_credentials grant for new listeners; Salesforce is retiring the username-password flow.
{
"GrantType": "client_credentials",
"ClientId": "Bn8UmtiLydmYQV6//qCL5dqfNUMhqchdk959hu0XXgauGMYAmYoyWN8FD+voGuMwGyJa7onrc60q1Hu6QFsQXHVA==",
"ClientSecret": "DyU1hqde3cWwkPOwK97T6rzwqv6t3bgQeCGq/fUx+tKI=",
"InstanceAuthUrl": "https://mydomain.my.salesforce.com/services/oauth2/token"
}
Every column in the schema must be a field of the Salesforce object, including Id. Because Cinchy reads each changed record back from Salesforce, any field of the object can be mapped, formula fields included.
The Schema section is where you define which source columns you want to sync in your connection. You can repeat the values for multiple columns.
| Parameter | Description | Example |
|---|---|---|
| Name | Mandatory. The name of your column as it appears in the source. | Name |
| Alias | Optional. You may choose to use an alias on your column so that it has a different name in the data sync. | |
| Data Type | Mandatory. The data type of the column values. | Text |
| Description | Optional. You may choose to add a description to your column. |
Select Show Advanced for more options for the Schema section.
| Parameter | Description | Example |
|---|---|---|
| Mandatory |
| |
| Validate Data |
| |
| Trim Whitespace | Optional if data type = text. For Text data types, you can choose whether to trim the whitespace._ | |
| Max Length | Optional if data type = text. You can input a numerical value in this field that represents the maximum length of the data that can be synced in your column. If the value is exceeded, the row will be rejected (you can find this error in the Execution Log). |
You can choose to add in a Transformation > String Replacement by inputting the following:
| Parameter | Description | Example |
|---|---|---|
| Pattern | Mandatory if using a Transformation. The pattern for your string replacement. | |
| Replacement | What you want to replace your pattern with. |
Change Data Capture publishes every change to the object. To sync only some records, add a source filter to your data sync. Please review the documentation here for more information on source filters.
Sync key
The sync key must be the single destination column that is mapped from the Id source column. A change event for a deleted record carries only the record Id, so no other column can identify the target row. The listener checks this when it starts and refuses to start otherwise.
Next steps
- Configure your Destination
- Define your Sync Actions.
- Add in your Post Sync Scripts, if required.
- If more than one listener is needed for a real-time sync, configure it/them via the Listener Config table.
- To run a real-time sync, enable your Listener from the Execution tab.