PlatformEventChannel
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 | PlatformEventChannelSelectedEntity[] | Removed. A list of event names of entities, including standard and custom objects, selected for Change Data Capture notifications. |
channelType | PlatformEventChannelType (enumeration of type string) | Required. The channel type. Valid values are:
|
eventType | PlatformEventChannelEventType (enumeration of type string) | The type of events that the channel can hold. A channel can hold
only one type of events. Use this field to optionally specify a
specific type of events for a channel in combination with the
channelType field. Valid values are:
Available in API version 61.0 and later. |
label | string | Required. The channel label. |
PlatformEventChannelSelectedEntity
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.
You can delete a custom channel with destructiveChanges.xml. If you delete a custom channel, all its member PlatformEventChannelMember components are also deleted.
You can update only the fullName field and the label field of a PlatformEventChannel component.
Declarative Metadata Sample Definition for a Custom Channel
The PlatformEventChannel component contains the label of the custom channel and the channel type.
<?xml version="1.0" encoding="UTF-8"?>
<PlatformEventChannel xmlns="http://soap.sforce.com/2006/04/metadata">
<channelType>data</channelType>
<label>Custom Channel for Sales Events</label>
</PlatformEventChannel>
This package.xml references the previous definition. The custom channel name is SalesEvents__chn.
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>SalesEvents__chn</members>
<name>PlatformEventChannel</name>
</types>
<version>64.0</version>
</Package>
Wildcard Support in the Manifest File
To deploy or retrieve all custom channels, specify the wildcard character * (asterisk) in the <members> field.
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>*</members>
<name>PlatformEventChannel</name>
</types>
<version>64.0</version>
</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.
<?xml version="1.0" encoding="UTF-8"?>
<PlatformEventChannel xmlns="http://soap.sforce.com/2006/04/metadata">
<channelMembers>
<selectedEntity>AccountChangeEvent</selectedEntity>
</channelMembers>
<channelMembers>
<selectedEntity>ContactChangeEvent</selectedEntity>
</channelMembers>
<channelType>data</channelType>
<label>Sales Events</label>
</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.
<?xml version="1.0" encoding="UTF-8"?>
<PlatformEventChannel xmlns="http://soap.sforce.com/2006/04/metadata">
<channelType>data</channelType>
<label>SalesEvents__chn</label>
</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.
<?xml version="1.0" encoding="UTF-8"?>
<PlatformEventChannelMember xmlns="http://soap.sforce.com/2006/04/metadata">
<eventChannel>SalesEvents__chn</eventChannel>
<selectedEntity>AccountChangeEvent</selectedEntity>
</PlatformEventChannelMember>
For more information, see PlatformEventChannelMember.
For an example of a custom channel that holds custom platform events and Real-Time Event Monitoring events, see Group Platform Events into One Stream with a Custom Channel in the Platform Events Developer Guide.