Skip to main content
Join the Agentforce Hackathon on Nov. 18-19 to compete for a $20,000 Grand Prize. Sign up now. Terms apply.

Receive an Enriched Change Event

You added a channel member to enable notifications for Account and to add enriched fields. Next, you receive a change event and verify it contains the enriched fields. 

To subscribe to the channel, we use an app from AppExchange, the Streaming Monitor app. 

Install Streaming Monitor from the AppExchange

If you’re using a Trailhead Playground org, you should have the prerequisites for the Streaming Monitor app and you can proceed with the installation steps. If you aren’t using a Trailhead Playground org, make sure that Lightning Experience is enabled in your org. For more information, see Verify that Lightning Experience is Turned On in Salesforce Help.

Installation Steps  

In your Trailhead Playground, if you see a tab in your org labeled Install a Package, great! Follow these steps: 

  1. Click the Install a Package tab.
  2. Paste 04t1t000003Lgqi into the field.
  3. Click Install.
  4. Select Install for Admins Only, then click Install.

If you don't see the Install a Package tab, open the App Launcher (App Launcher), find Playground Starter, and follow the steps.

If you don’t see the Playground Starter app, copy this package installation link and check out Install a Package or App to Complete a Trailhead Challenge  on Salesforce Help.

When the package is finished installing, you see a confirmation page and get an email to the address associated with your playground.

Note

The Streaming Monitor AppExchange app is developed by Salesforce Labs. It is used as an example tool in this project. Salesforce Labs supports this tool but not Salesforce. Streaming Monitor is also available as an open-source tool in GitHub that you can contribute to. Alternatively, you can use the empApi Lightning component in your custom Lightning app. To receive events in an external client, you can use the EMP Connector open-source, community-supported tool. For more information about EMP Connector, see the Subscribe to an Event Channel unit in the Change Data Capture Basics Trailhead module. 

Subscribe to the Channel and Receive an Initial Change Event

Use Streaming Monitor to subscribe and receive an initial change event after creating a new account record. Let's get an initial event message to try things out. 

Subscribe to the Custom Channel

After you’ve installed Streaming Monitor, launch it to subscribe to the custom channel.

  1. Click App Launcher, and enter Streaming Monitor in the search box. Select Streaming Monitor.
  2. In the Streaming Monitor app, under Actions, click Subscribe to a channel.
  3. Under Event type, select Custom Channel - Change event.
  4. For the channel, append SalesEvents__chn. The full channel name is /data/SalesEvents__chn.
  5. Click Subscribe.
  6. You get a popup that confirms the successful subscription. Dismiss it.

Launch the Streaming Monitor app

Note

If you receive a "A Component Error has occurred" error message, clear your browser cache. If needed, sign into your Trailhead Playground again.

Create an Account Record

  1. Click App Launcher, and enter Accounts in the search box.
  2. Right-click Accounts and select to open the link in a new tab.
  3. In the new tab, search for Accounts in App Launcher.
  4. Create an account with these values.
    1. Account Name: Astro
    2. Industry: Apparel
    3. External Account ID: 123
    4. Phone: 4155551212
  1. Switch to the Streaming Monitor tab. A new event appears in the timeline view as a dot.An event appears in the timeline view of Streaming Monitor
  2. To view the event message, click the dot, which represents the received event. The event payload looks similar to this example.
{
  "LastModifiedDate": "2023-08-29T19:22:19Z",
  "External_Account_ID__c": "123",
  "Name": "Astro",
  "Industry": "Apparel",
  "Phone": "4155551212",
  "OwnerId": "0058b00000HpWcRAAV",
  "CreatedById": "0058b00000HpWcRAAV",
  "CleanStatus": "Pending",
  "ChangeEventHeader": {
    "commitNumber": 11658980597990,
    "commitUser": "0058b00000HpWcRAAV",
    "sequenceNumber": 1,
    "entityName": "Account",
    "changeType": "CREATE",
    "changedFields": [],
    "changeOrigin": "com/salesforce/api/soap/58.0;client=SfdcInternalAPI/",
    "transactionKey": "00006bed-29af-3dd6-128a-a534cde0836f",
    "commitTimestamp": 1693336939000,
    "recordIds": [
      "0018b00002Vlq7xAAB"
      ]
    },
  "CreatedDate": "2023-08-29T19:22:19Z",
  "LastModifiedById": "0058b00000HpWcRAAV"
}
Note

Streaming Monitor shows only the payload part of the event message. The event replay ID and schema are omitted for brevity. 

This event isn’t enriched yet with extra fields because it is for a create operation. Enrichment is available for update and delete operations. However, it does contain the External_Account_ID__c and Industry fields. Why? The fields are present because they’re added as part of the new populated fields, and not as enriched fields. 

Receive an Enriched Change Event

Let’s validate that enriched fields are indeed added to change events. While still subscribed to the SalesEvents__chn channel, you update the same record and wait for a change event. 

  1. Switch to the tab for the account you created earlier.
  2. Edit the Type field and select Customer - Direct.
  3. Save the record.
  4. Switch to Streaming Monitor. To view the new event payload, click the dot representing the event that comes after the previous event in the timeline.
{
  "LastModifiedDate": "2023-08-29T19:26:11Z",
  "External_Account_ID__c": "123",
  "Industry": "Apparel",
  "Type": "Customer - Direct",
  "ChangeEventHeader": {
    "commitNumber": 11658983493935,
    "commitUser": "0058b00000HpWcRAAV",
    "sequenceNumber": 1,
    "entityName": "Account",
    "changeType": "UPDATE",
    "changedFields": [
    "Type",
    "LastModifiedDate"
    ],
    "changeOrigin": "com/salesforce/api/soap/58.0;client=SfdcInternalAPI/",
    "transactionKey": "000156e3-6f79-5781-b351-6085bc252aaf",
    "commitTimestamp": 1693337171000,
    "recordIds": [
      "0018b00002Vlq7xAAB"
    ]
  }
}

Even though only the Type field was updated, the event payload also includes the enriched fields, External_Account_ID__c and Industry, as shown in this example event. The changedFields field shows what fields changed. In this case, it contains the Type field. In addition, this update caused the LastModifiedDate field to change, so it is listed also as a changed field. 

Resources

Teilen Sie Ihr Trailhead-Feedback über die Salesforce-Hilfe.

Wir würden uns sehr freuen, von Ihren Erfahrungen mit Trailhead zu hören: Sie können jetzt jederzeit über die Salesforce-Hilfe auf das neue Feedback-Formular zugreifen.

Weitere Infos Weiter zu "Feedback teilen"