Newer Version Available
Obtain Apex Trigger Subscribers
To get information about the triggers that are subscribed to change events, query the
EventBusSubscriber standard object using SOQL. EventBusSubscriber contains information about Apex
triggers but not CometD or Pub/Sub API subscribers.
Example
This example SOQL query selects several fields from EventBusSubscriber. For more information about EventBusSubscriber fields, see EventBusSubscriber in the Object Reference for Salesforce and Lightning Platform.
The returned result shows that there are two Apex triggers subscribed to change events. One trigger is subscribed to AccountChangeEvent and one to ContactChangeEvent.
| ExternalId | Name | Topic | Position | Status | Tip | Type |
|---|---|---|---|---|---|---|
| 01q2J000000g0kb | MyAccountChangeTrigger | AccountChangeEvent | 226751 | Running | -1 | ApexTrigger |
| 01q2J000000g0kg | MyContactChangeTrigger | ContactChangeEvent | 226752 | Running | -1 | ApexTrigger |
You can filter the query results by using a WHERE clause. For example, this query filters by the topic ContactChangeEvent.
The query returns only the trigger subscribers to ContactChangeEvent, in this case, one trigger.
| ExternalId | Name | Topic | Position | Status | Tip | Type |
|---|---|---|---|---|---|---|
| 01q2J000000g0kg | MyContactChangeTrigger | ContactChangeEvent | 226752 | Running | -1 | ApexTrigger |