We started an initiative and were in process of testing a POC using CDC for the first time in Salesforce. We knew of the 5 object limit when utilizing this feature and we were able to work with this.

Initial tests with custom fields worked just fine. We have a change event trigger on the Contact object and when a field value is added/updated, it creates a serialized JSON string and sends it to an AWS API gateway so we can process/enrich/utilize it with lambdas.

All worked as expected until we added a formula field to the Contact object and didn't see it send in the change event payload. Turns out there is a consideration that we overlooked where formula fields are not supported.

We now need to handle this situation differently as the native CDC functionality won't work in this case.

Example Trigger:

* ContactChangeTrigger
* Send POST request to AWS Change Event API after ContactChangeEvent

trigger ContactChangeTrigger on ContactChangeEvent (after insert) {

    // Iterate through each event message
    for (ContactChangeEvent event : Trigger.New) {
        // Get some event header fields
        EventBus.ChangeEventHeader header = event.ChangeEventHeader;
        // Serialize to JSON
        String json = JSON.serialize(event, true);
        // Send async request

        System.debug('Sent asynchronous POST request!');

APEX Callout for AWS:

public static void sendRequestAsync(String content) {

    // Attempt to send data to the AWS endpoint
    try {
        APIGateway.dt = Datetime.now();
        APIGateway.d = APIGateway.getDate();
        APIGateway.timestamp = APIGateway.getTimestamp();
        APIGateway.content = content;

        AWS_Configuration__c awsConfig = AWS_Configuration__c.getOrgDefaults();
        APIGateway.REQUEST_PATH = awsConfig.Request_Path__c;

        HttpRequest req = new HttpRequest();
        req.setEndpoint('callout:AWS' + APIGateway.REQUEST_PATH);
        req.setHeader('Content-Type', APIGateway.CONTENT_TYPE);
        req.setHeader('X-Amz-Date', APIGateway.timestamp);

        Http http = new Http();
    } catch (Exception e) {
        // Handle

Since we were relying on change events to send over the fields that changed, that needs to be handled differently.

I came across this example of a trigger to determine fields that changed. I am wondering if there is a better way that can avoid hardcoding checks of every field and somehow only send over the serialized fields that changed in someone based on old and new in the trigger?

Essentially, I need to do a delta on the field changes to be able to send over the changed data.

Worse case, I don't have to do the delta here and can just send over all of the new data and then possibly handle that in the lambdas instead.

Any thoughts on a good approach? CDC would have worked just fine if it supported formula fields, but the lack of support there now forces me to take another path.

  • @PranayJaiswal We were originally using CDC so that we only need to send changed data to AWS for processing. If the Contact object has 100 fields and we only changed 1, CDC would only send the fields in the event that actually contained data or changed in some way, reducing overhead, payload sizes, etc. It sounds like it may need to be an all or nothing though as calculating changes in a trigger (future) may not work.
    – SBB
    Sep 22, 2021 at 13:47
  • help.salesforce.com/s/… this still doesn not support formula fields. And there is no plans of adding it as per trailhead group. Sep 22, 2021 at 13:53


You must log in to answer this question.

Browse other questions tagged .