Newer Version Available

This content describes an older version of this product. View Latest

Example: Add Event Enrichment Fields with Metadata API

To add event enrichment fields, use the PlatformEventChannelMember metadata type, and specify the fields, the channel, and channel member.

We provide Change Data Capture Enrichment to selected customers through a pilot program that requires agreement to specific terms and conditions. To be nominated to participate in the program, contact Salesforce. Pilot programs are subject to change, and we can’t guarantee acceptance. Change Data Capture Enrichment isn’t generally available unless or until Salesforce announces its general availability in documentation or in press releases or public statements. We can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features. You can provide feedback and suggestions for Change Data Capture Enrichment in the Trailblazer Community.

Note

If the channel member you are enriching is part of a custom channel, create the custom channel first, as shown in this example. You can skip this step if using the ChangeEvents standard channel, or if you created the custom channel earlier.

This sample metadata component is for a custom channel.

1<?xml version="1.0" encoding="UTF-8"?>
2<PlatformEventChannel xmlns="http://soap.sforce.com/2006/04/metadata">
3    <channelType>data</channelType>
4    <label>Custom Channel for Sales Events</label>
5</PlatformEventChannel>

This package.xml references the previous definition. The custom channel name is SalesEvents__chn.

1<?xml version="1.0" encoding="UTF-8"?>
2<Package xmlns="http://soap.sforce.com/2006/04/metadata">
3    <types>
4        <members>SalesEvents__chn</members>
5        <name>PlatformEventChannel</name>
6    </types>
7    <version>48.0</version>
8</Package>

To add enrichment fields, deploy the PlatformEventChannelMember component containing the enriched fields. In this example, the component contains two enriched fields for AccountChangeEvent on the SalesEvents custom channel. External_Account_ID__c is a custom field defined in your org.

1<?xml version="1.0" encoding="UTF-8"?>
2<PlatformEventChannelMember xmlns="http://soap.sforce.com/2006/04/metadata">
3    <enrichedFields>
4        <name>External_Account_ID__c</name>
5    </enrichedFields>
6    <enrichedFields>
7        <name>Industry</name>
8    </enrichedFields>
9    <eventChannel>SalesEvents__chn</eventChannel>
10    <selectedEntity>AccountChangeEvent</selectedEntity>
11</PlatformEventChannelMember>

Use this package.xml manifest file to deploy or retrieve the channel member definition. Only API version 48.0 and later is supported.

1<?xml version="1.0" encoding="UTF-8"?>
2<Package xmlns="http://soap.sforce.com/2006/04/metadata">
3    <types>
4        <members>SalesEvents_AccountChangeEvent</members>
5        <name>PlatformEventChannelMember</name>
6    </types>
7    <version>48.0</version>
8</Package>

If the member is already part of the channel, you can update it with enriched fields by redeploying the PlatformEventChannelMember component with an updated definition.

Note