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

No Results

Search Tips:

  • Please consider misspellings
  • Try different search keywords

項目にフラグを設定するトリガの設定

コミュニティ内の特定の条件を満たす項目に自動的にフラグを設定するには、トリガを使用します。

必要なユーザ権限
トリガを作成する 「すべてのデータの編集」

トリガを使用して自動的に項目にフラグを設定すると、コミュニティをバックグラウンドでモデレートできます。フラグはモデレータにのみ表示されます。[コミュニティ管理] ページでの [フラグ付き投稿] フィード内のフラグの表示、API でのフラグのクエリ、カスタムレポートタイプを使用したフラグ付き項目やフラグ付き項目が最も多いユーザなどに関するレポートの作成ができます。

トリガを作成するときは、次の点に留意してください。

  • Apex は、FeedItem、FeedComment、または ContentDocument にトリガを挿入した後に作成します。
  • 条件は、満たされたら FeedComment、FeedItem、または ContentDocument を親として NetworkModeration (フラグ) レコードを作成するように定義します。

次に、サンプルトリガを示します。

次のトリガは、コミュニティ内の BadWord を含む投稿に自動的にフラグを設定します。

1trigger autoflagBadWord on FeedItem (after insert) {
2    for (FeedItem rec : trigger.new) {
3        if (!<CommunityId>.equals(rec.networkScope))
4            continue;
5
6        if (rec.body.indexOf('BadWord') >= 0) {
7            NetworkModeration nm = new NetworkModeration(entityId=rec.id, visibility='ModeratorsOnly');
8            insert(nm);
9        }
10    }
11}

コメントに対する同様のトリガは、次のようになります。

1trigger autoflagBadWord on FeedComment (after insert) {
2    for (FeedComment rec : trigger.new) {
3        if (!<CommunityId>.equals(rec.networkScope))
4            continue;
5
6        if (rec.commentBody.indexOf('BadWord') >= 0) {
7            NetworkModeration nm = new NetworkModeration(entityId=rec.id, visibility='ModeratorsOnly');
8            insert(nm);
9        }
10    }
11}