Newer Version Available

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

Obtain Apex Triggers That Subscribe to a Platform Event

View a list of all triggers that are subscribed to a platform event by using the Salesforce user interface or the API.
  1. From Setup, enter Platform Events in the Quick Find box, then select Platform Events.
  2. Click your event’s name.

On the event’s definition page, the Subscriptions related list shows all the active triggers that are subscribed to platform events. The list shows the replay ID of the event that the system last processed (Last Processed Id field) and the event last published (Last Published Id field). Knowing which replay ID was last processed is useful when there is a gap in the events published and processed. For example, if a trigger contains complex logic that causes a delay in processing large batches of incoming events.

For high-volume platform events, the Last Published Id value is not available and is always -1.

Note

Also, the Subscriptions list shows the state of each subscribed trigger. Trigger states can be one of the following.

  • Running—The trigger is actively listening to events.
  • Idle—The trigger hasn't received events for some time and is not actively listening to events. When new events are sent, the trigger receives the new events after a short delay and switches to the Running state.
  • Error—The trigger has been disconnected and stopped receiving published events. A trigger reaches this state when it exceeds the number of maximum retries with the EventBus.RetryableException. Trigger assertion failures and unhandled exceptions don’t cause the Error state. To resume trigger execution, fix the trigger code and save it. For a managed package trigger, redeploy the package after fixing the trigger.
  • Suspended—The trigger is disconnected and can’t receive events due to an internal error. To resume trigger execution, try saving the trigger again. For a managed package trigger, redeploy the package.

CometD subscribers to a platform event channel aren’t listed in the Subscriptions related list. Only one “Process” subscriber appears in the Subscriptions related list for all processes and flows that are subscribed to the platform event.

Note

Alternatively, you can obtain the same subscriber information by querying the EventBusSubscriber object. See EventBusSubscriber.