we can use Change Events to synchronize changes to the Salesforce records in your ERP(Enterprise resource planning) system. You can subscribe to change events the same way you subscribe to other events, like PushTopic events or platform events.
In this case, we don’t have a SQL to select which data is needed to be sent. All changed data will be automatically sent as events to the Agent. For the CDC event, we just need to set the flag, select the xxxChangeEvent object in the interface on the field ‘Source/Target’ field, for example, AccountChangeEvent, or LeadChangeEvent, OpportunityChangeEvent, etc.. In the message type again we put the external message type. Then we can do the mapping from the sObject field to the external message type. The flow is the same that when the user change, insert, delete, or undelete data an event is created and the Agent will receive all the field that has been changed. In Agent, we are checking the mapping and transform the event data to the external structure based on the mapping. This means that when there is no mapping we need to raise an error and write into the log.
We don’t need to select the operation ‘Insert’, ‘Update’, ‘Delete’ and ‘Undelete’. This operation is pre-selected by default setting when the CDC event is used. Therefore there is no need to configure this operation as we do for the CDC Event trigger with apex. Like case 1) we also create a message for the monitoring. Also, this kind of message cannot be reprocessed by the reprocessing job
- Create Integration.
- Create metadata provider -> Create Istructure Repository -> Create msg type.
- Create Adapter with new agent control board. Here we are using agent file adapter with linux.
- Select Object for Change data capture:- From Setup, enter Change data capture in the Quick Find box.- Select-Object.
– Save it.
Here we are elaborating each step with screenshot.
Step1: We have to create Message Type for Istructure.
Create Integration. And navigate to New agent control board trough a custom link.
Once Agent control board is open. We have to configure agent with config details.
Click on ping agent connection button.
Step3: Create Adapter. Here we are using Agent file adapter. You can reffer this tutorial to create file adapter: How to create file adapter .
Step4: Go to Integration -> Interface Tab -> Click on New Interface button. We have to create Outbound Interface where:
- Interface type=”Event-Interface”.
- source name contains “ChangeEvent” e.g. AccountChangeEvent
- Step 5: Go to New agent control board -> Interface tab
On the Interface tab, there is a streaming button on the interface list. click start Streaming Api (make sure you can connect to the agent)
Step 6: Change a Salesforce record and you will see the record is pushed to your external system. You can check the message monitoring to see the result.
Test.csv file is generated in your system.