Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.
NotificationAction Interface
Namespace
Usage
Report notifications for reports that users have subscribed to can trigger a custom Apex class, which must implement the Reports.NotificationAction interface. The execute method in this interface receives a NotificationActionContext object as a parameter, which contains information about the report instance and the conditions that must be met for a notification to be triggered.
NotificationAction Methods
The following are methods for NotificationAction.
execute(context)
Signature
public void execute(Reports.NotificationActionContext context)
Parameters
- context:
Return Value
Type: Void
NotificationAction Example Implementation
This is an example implementation of the Reports.NotificationAction interface.
1public class AlertOwners implements Reports.NotificationAction {
2
3 public void execute(Reports.NotificationActionContext context) {
4 Reports.ReportResults results = context.getReportInstance().getReportResults();
5 for(Reports.GroupingValue g: results.getGroupingsDown().getGroupings()) {
6 FeedItem t = new FeedItem();
7 t.ParentId = (Id)g.getValue();
8 t.Body = 'This record needs attention. Please view the report.';
9 t.Title = 'Needs Attention: '+ results.getReportMetadata().getName();
10 t.LinkUrl = '/' + results.getReportMetadata().getId();
11 insert t;
12 }
13 }
14}