Newer Version Available
EventSubscription
Represents a subscription to an event type.
This type extends the Metadata
metadata type and inherits its fullName field.
File Suffix and Directory Location
EventSubscription components have the suffix file path .subscription, and are stored in the eventSubscriptions folder.
Version
Event subscription components are available in API version 41.0 and later.
Fields
| Field Name | Field Type | Description |
|---|---|---|
| active | boolean | If the subscription isn’t active, it never receives any events. |
| eventParameters | EventParameterMap[] | An array of parameters that must be true for published events. |
| eventType | string | Required. The name of the platform event. |
| referenceData | string | Required. If the subscriber is a flow of type CustomEvent, referenceData is flowName_versionNumber. For example, Printer_Management_2. |
EventParameterMap
An array of parameters that must be true for published events. For example, subscribe to Vendor Response events only if Status__c is Shipped.
Each event subscription can have up to 10 parameters.
| Field Name | Field Type | Description |
|---|---|---|
| parameterName | string | Required. The published event’s field name. |
| parameterValue | string | The value that must be true. |
Declarative Metadata Sample Definition
The following is an example of an active event subscription.
1<?xml version="1.0" encoding="UTF-8"?>
2<EventSubscription xmlns="http://soap.sforce.com/2006/04/metadata">
3 <active>true</active>
4 <eventType>Printer_Status__e</eventType>
5 <referenceData>Printer_Management</referenceData>
6</EventSubscription>The following is an example of an inactive event subscription that sets event parameters.
1<?xml version="1.0" encoding="UTF-8"?>
2<EventSubscription xmlns="http://soap.sforce.com/2006/04/metadata">
3 <name>MySubscription</name>
4 <active>false</active>
5 <eventParameters>
6 <parameterName>Ink_Status__c</parameterName>
7 <parameterValue>low</parameterValue>
8 </eventParameters>
9 <eventParameters>
10 <parameterName>Serial_Number__c</parameterName>
11 <parameterValue>00123456789</parameterValue>
12 </eventParameters>
13 <eventType>Printer_Status__e</eventType>
14 <referenceData>My_Event_Based_Process_1</referenceData>
15</EventSubscription>The following is an example package.xml that deploys or retrieves all the available event subscription metadata in your org.
1<?xml version="1.0" encoding="UTF-8"?>
2<Package xmlns="http://soap.sforce.com/2006/04/metadata">
3 <types>
4 <members>EventSubscription</members>
5 <name>*</name>
6 </types>