Newer Version Available
Subscribe to Publish Status Events with an Apex Trigger (Beta)
Alternatively, you can subscribe to publish status events with an Apex trigger.
Create an after insert trigger on
PublishStatusEvent.
Trigger.New contains the received PublishStatusEvent messages. For each status event, you can obtain the event fields, such as the status and topic. Then you can get information about each event, including the EventUuid, in the PublishStatusDetails field.
This Apex trigger example iterates over every PublishStatusEvent and logs information about the failed event publishes in PublishResult__c custom object records.
Prerequisites: Before you can save this example, create a custom object with the label PublishResult and with these fields:
- Type: Text(36), Label: EventUuid
- Type: Number(18,0), Label: ReplayId
- Type: Text(50), Label: StatusCode
- Type: Text(255), Label: FailureReason
- Type: Text(255), Label: Topic
- Type: Text(25), Label: Status