この文章は Salesforce 機械翻訳システムを使用して翻訳されました。詳細はこちらをご参照ください。
英語に切り替える

Newer Version Available

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

NotificationAction インターフェース

レポート通知の条件を満たした場合にカスタム Apex クラスをトリガするにはこのインターフェースを実装します。

名前空間

Reports

使用方法

ユーザが登録したレポートのレポート通知から、Reports.NotificationAction インターフェースが実装されたカスタム Apex クラスをトリガできます。このインターフェースの execute メソッドが NotificationActionContext オブジェクトをパラメータとして受信します。このオブジェクトには、レポートインスタンスと、通知をトリガするために満たさなければならない条件に関する情報が含まれます。

NotificationAction メソッド

NotificationAction のメソッドは次のとおりです。

execute(context)

コンテキストオブジェクト NotificationActionContextcontext パラメータで指定されたカスタム Apex アクションを実行します。オブジェクトには、レポートインスタンスと、通知をトリガするために満たさなければならない条件に関する情報が含まれます。メソッドは、指定された条件が満たされるたびに実行されます。

署名

public void execute(Reports.NotificationActionContext context)

パラメータ

context
型: Reports.NotificationActionContext

戻り値

型: Void

NotificationAction の実装例

これは、Reports.NotificationAction インターフェースの実装例です。

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}