イベントの作成

  • リリースバージョン: Washingtondc
  • 更新日 2024年02月01日
  • 読む3読むのに数分
  • 適切な既存のイベントがない場合は、独自のイベントを作成できます。

    始める前に

    必要なロール:管理者

    このタスクについて

    gs.EventQueue 関数はバックエンドと直接連携するため、gs.EventQueue() によって呼び出されるビジネスルールは呼び出されません。

    手順

    1. 移動先 すべて > システムポリシー > イベント > レジストリ.
    2. [新規] をクリックし、フォームに入力します。
    3. [ビジネスルール] 関連リンクをクリックします。
    4. ベースシステムテーブルのイベントを作成する場合は、テーブルの既存のイベントビジネスルールを選択します。
      たとえば、sc request events ビジネスルールを選択してカスタム要求イベントを作成します。
    5. 既存のイベントビジネスルールを更新する場合は、[スクリプト] に新しい条件を追加します。
      次のサンプルスクリプトは、ユーザーのシステム ID が parm1 で、ユーザーのユーザー名が parm2 の request.commented イベントを追加します。
      if (current.operation() != 'insert' && current.comments.changes()) {
      gs.eventQueue('request.commented', current, gs.getUserID(), gs.getUserName());
      }
    6. カスタムテーブルのイベントを作成する場合は、データベース操作の後に実行される新しいビジネスルールを作成します。
      たとえば、次のビジネスルールは、マーケティングイベントと呼ばれるカスタムアプリケーションに対していくつかのイベントを定義します。
      表 : 1. イベントビジネスルールのサンプル
      フィールド
      名前 出席者のイベント
      テーブル 出席者 [x_snc_marketing_ev_attendee]
      アプリケーション マーケティングイベント
      詳細 選択済み
      時期 トランザクションの後
      挿入 選択済み
      更新 選択済み
      削除 選択済み
      スクリプト
      次のようなカスタムスクリプトを追加します。
      • 現在のレコードで 1 つ以上の条件をチェックします。
      • gs.eventQueue() メソッドを呼び出し、イベント名を指定します。

      コードサンプルを参照してください。

      注:
      [フィルター条件][ロールの条件]、または [条件] 値を追加する場合は、想定どおりにビジネスルールが実行されることを確認します。
      (function executeRule(current, previous /*null when async*/) {
         //This function will be automatically called when this rule is processed.
              //Add event when attendee inserted
              if(current.operation() == 'insert' && current.marketing_event.changes()) {
                      gs.eventQueue('x_snc_marketing_ev.attendee.added', current,
      current.marketing_event, current.email);
              }
              //Add event when marketing event changes
              if(current.operation() == 'update' && current.marketing_event.changes()) {
                      gs.eventQueue('x_snc_marketing_ev.attendee.deleted', previous,
      previous.marketing_event, previous.email);
                      gs.eventQueue('x_snc_marketing_ev.attendee.added', current,
      current.marketing_event, current.email);
              }
              //Add event when attendee deleted
              if(current.operation() == 'delete') {
                      gs.eventQueue('x_snc_marketing_ev.attendee.deleted', current,
                    current.marketing_event, current.email);
      }
      })(current, previous);
    7. イベントを登録します。

    次のタスク

    イベントを処理するスクリプトアクションまたは通知を作成します。