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.
The following are methods for NotificationAction.
public void execute(Reports.NotificationActionContext context)
Type: Void
This is an example implementation of the Reports.NotificationAction interface.
public class AlertOwners implements Reports.NotificationAction { public void execute(Reports.NotificationActionContext context) { Reports.ReportResults results = context.getReportInstance().getReportResults(); for(Reports.GroupingValue g: results.getGroupingsDown().getGroupings()) { FeedItem t = new FeedItem(); t.ParentId = (Id)g.getValue(); t.Body = 'This record needs attention. Please view the report.'; t.Title = 'Needs Attention: '+ results.getReportMetadata().getName(); t.LinkUrl = '/' + results.getReportMetadata().getId(); insert t; } } }