Newer Version Available

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

PlatformEventChannel

Represents a Change Data Capture standard or custom channel that you can subscribe to for receiving notifications of Salesforce record changes. The standard channel corresponds to the entity selection in the Change Data Capture page in Setup. A custom channel is a channel that you define using this metadata type. Starting in API version 47.0, the channel doesn’t contain the selected entities, which are represented each by PlatformEventChannelMember. In API version 46.0 and earlier, the channel includes the selected entities. Change Data Capture sends notifications for created, updated, deleted, and undeleted records only for the selected entities. This type extends the Metadata metadata type and inherits its fullName field.

File Suffix and Directory Location

PlatformEventChannel components have the suffix .platformEventChannel and are stored in the platformEventChannels folder.

Version

PlatformEventChannel components are available in API version 45.0 and later.

Special Access Rules

You must have the Customize Application permission to deploy and retrieve this type.

Fields

Field Name Field Type Description
channelMembers PlatformEventChannel​SelectedEntity[] Removed. A list of event names of entities, including standard and custom objects, selected for Change Data Capture notifications.

This field is removed in API version 47.0 and later and is available only in API versions 45.0 and 46.0. In API version 47.0 and later, the channel members are each defined in a PlatformEventChannelMember component.

Note

channelType PlatformEventChannel​Type (enumeration of type string) Required. The channel type. Valid values are:
  • data—Change Data Capture channel corresponding to the selected entities.
  • event—Reserved for future use.
label string Required. The channel label.

PlatformEventChannelSelectedEntity

This field type is removed in API version 47.0 and later and is available only in API versions 45.0 and 46.0.

Note

Field Name Field Type Description
selectedEntity string Required. The event name of an entity selected for Change Data Capture notifications. For example, for the Account standard object, the name is AccountChangeEvent, or for a custom object MyObject__c, the name is MyObject__ChangeEvent.

Usage

The createMetadata() and deleteMetadata() calls aren’t supported with the PlatformEventChannel metadata type.

In API version 47.0 and later, you can’t deploy or retrieve the ChangeEvents standard channel.

You can't delete the ChangeEvents standard channel with destructiveChanges.xml, but you can delete channel members using the PlatformEventChannelMember type with destructiveChanges.xml.

Declarative Metadata Sample Definition for a Custom Channel

The PlatformEventChannel component contains the label of the custom channel and the channel type.

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>47.0</version>
8</Package>

Wildcard Support in the Manifest File

To deploy or retrieve all custom channels, specify the wildcard character * (asterisk) in the <members> field.

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

Upgrading to Version 47.0 or Later From an Earlier Version

The channelMembers field of the PlatformEventChannel type is removed in API version 47.0 and later. As a result, PlatformEventChannel components created in prior versions can’t be deployed using a later API version but you can deploy them in the same API version they were created with.

To deploy a custom channel component using API version 47.0 and later, upgrade the PlatformEventChannel definition by removing the <channelMembers> fields. For the ChangeEvents standard channel, it can’t be deployed or retrieved, so delete the PlatformEventChannel definition file.

For example, if you had custom channel called SalesEvents__chn, this could be your custom channel definition in API version 46.0.

1<?xml version="1.0" encoding="UTF-8"?>
2<PlatformEventChannel xmlns="http://soap.sforce.com/2006/04/metadata">
3    <channelMembers>
4        <selectedEntity>AccountChangeEvent</selectedEntity>
5    </channelMembers>
6    <channelMembers>
7        <selectedEntity>ContactChangeEvent</selectedEntity>
8    </channelMembers>
9    <channelType>data</channelType>
10    <label>Sales Events</label>
11</PlatformEventChannel>

To upgrade to version 47.0 or later, you would replace the custom channel definition with this definition, which doesn’t contain any channel members.

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

For each channel member that is part of either a custom or the standard ChangeEvents channel, add a PlatformEventChannelMember metadata component. Also, in the package.xml file, reference both the PlatformEventChannel and PlatformEventChannelMember components.

For example, this PlatformEventChannelMember component is for the AccountChangeEvent member.

1<?xml version="1.0" encoding="UTF-8"?>
2<PlatformEventChannelMember xmlns="http://soap.sforce.com/2006/04/metadata">
3    <eventChannel>SalesEvents__chn</eventChannel>
4    <selectedEntity>AccountChangeEvent</selectedEntity>
5</PlatformEventChannelMember>

For more information, see PlatformEventChannelMember.