Newer Version Available
PlatformStatusAlertEvent
For example, suppose that a formula is evaluated as part of processing user requests. A platform event message can be generated during the processing of a user request when an error is encountered from evaluating an invalid formula.
Supported Calls
describeSObjects()
Supported Subscribers
| Subscriber | Supported? |
|---|---|
| Apex Triggers | ![]() |
| Flows | ![]() |
| Processes | ![]() |
| Streaming API (CometD) | ![]() |
Streaming API Subscription Channel
/event/PlatformStatusAlertEvent
Fields
| Field | Details |
|---|---|
| ApiErrorCode |
|
| ComponentName |
|
| EventDate |
|
| EventIdentifier |
|
| ExtendErrorCode |
|
| RelatedEventIdentifier |
|
| ReplayId |
|
| RequestId |
|
| ServiceJobId |
|
| ServiceName |
|
| StatusType |
|
| SubComponentName |
|
| Subject |
|
| UserId |
|
| Username |
|
Usage
The following example shows how to trigger a platform status alert event. The event can be triggered only by internal services. This is an example of a trigger that fires when a platform event occurs and creates a chatter post on the admin profile with event details.
1trigger trigger1 on PlatformStatusAlertEvent (after insert) {
2 Id profileId = [select Id from User where User.Profile.Name = 'System Administrator' limit 1].Id;
3 for(PlatformStatusAlertEvent e : trigger.new) {
4 Feeditem Post = New Feeditem();
5 Post.ParentId= profileId;
6 Post.Body = 'Alert occured in the service: ' + e.ServiceName + '\n' +
7 'APIErrorCode: ' + e.APIErrorCode + '\n' +
8 'ComponentName: ' + e.ComponentName + '\n' +
9 'EventDate: ' + e.EventDate + '\n'+
10 'EventIdentifier: ' + e.EventIdentifier + '\n' +
11 'ExtendedErrorCode: '+ e.ExtendedErrorCode + '\n' +
12 'RelatedEventIdentifier: ' + e.RelatedEventIdentifier + '\n' +
13 'ReplayId: ' + e.ReplayId + '\n' +
14 'RequestId: ' + e.RequestId + '\n' +
15 'ServiceJobId: ' + e.ServiceJobId + '\n' +
16 'ServiceName: ' + e.ServiceName + '\n'+
17 'StatusType: ' + e.StatusType + '\n' +
18 'SubComponentName: ' + e.SubComponentName + '\n' +
19 'Subject: '+ e.Subject + '\n' +
20 'UserId: ' + e.UserId + '\n' +
21 'Username: ' + e.Username + '\n';
22 insert Post;
23 }
24}Example
The code example above ultimately displays as a Chatter post that contains the following:
Alert occured in the service: Next Best Action Strategy
APIErrorCode: INVALID_OPERATION
ComponentName: Strategy_for_error_event_demo
EventDate: 2018-12-18 21:59:48
EventIdentifier: null
ExtendedErrorCode: FORMULA_EXPRESSION_INVALID
RelatedEventIdentifier: null
ReplayId: 63
RequestId: TID:89715900005e40b69a
ServiceJobId: 1014fd4e-4a19-4910-be36-377a7f2f1b75
ServiceName: Next Best Action Strategy
StatusType: Error
SubComponentName: filter_node1
Subject: Something went wrong with filter element 'filter_node1': 'Unknown function ISBLANC. Check spelling.'
UserId: 005RM000001ZnzAYAS
Username: xxx@yyy.com
