インスタンスユーザーストーリー統合の構成

  • リリースバージョン: Australia
  • 更新日 2026年03月12日
  • 所要時間:6分
  • 本番インスタンスのストーリーを使用して、非本番環境からの結果を正式に追跡します。ServiceNow インスタンスユーザーストーリー統合を設定するには、次の手順を実行します。

    始める前に

    必要なロール:スキャンエンジンアドミン (sn_se.scan_engine_admin)

    手順

    1. インスタンスを登録します。
      インスタンスを登録」を参照してください。
    2. ユーザーストーリーテーブルを設定します。
      選択したテーブルが、レコードを挿入するターゲットテーブルになります。rm_story などのタスクベースのテーブルが一般的に選択されます。このテーブルは、ソースインスタンスとターゲットインスタンスの両方に存在する必要があります。
    3. 選択した ユーザーストーリーテーブル に基づいてフィールドの更新を動的に処理するように関連スクリプトをカスタマイズし、 ユーザーストーリーフィールドマッピング と使用可能なフィールドを定義します。

      これにより、スクリプティングを使用して、下位環境の結果から上位環境のストーリーへのマッピングを定義できます。たとえば、選択したテーブルで利用可能な [簡単な説明]、[ 説明]、またはその他のフィールドに入力する値を指定できます。

      デフォルトでは、有用な情報がガイドとして使用できるサンプルとともにコメントに表示されます。ニーズに合わせてスクリプトを設定します。

      ソースおよび宛先のインスタンス処理スクリプトを構成するときに、次の変数を使用できます。

      isSource
      ソースインスタンス (dev) で実行する場合は true に設定します。
      宛先
      宛先インスタンス (本番環境) で実行する場合は true に設定します。
      ペイロード
      インスタンス間で情報を渡すために使用されるユーザー定義の変数。
      grFinding
      要求を送信している検出結果の GlideRecord。ソースインスタンスでのみ定義されます。使用可能なフィールドは、 sn_se_finding テーブルのフィールドです。
      grTask
      宛先インスタンスで作成される GlideRecord。宛先インスタンスでのみ定義されます。使用可能なフィールドは、[ ユーザーストーリーテーブル ] 列で選択したテーブルのフィールドです。

      isSourcetrue の場合、スクリプトはソースインスタンスでのみ実行されます。このブロックを使用して、結果レコードから変数を含む ペイロード オブジェクトをロードします。使用可能なフィールドは、 sn_se_finding テーブル内のフィールドです。

      if (isSource) {
            // This logic is ONLY executed on the SOURCE instance.
            // Load the 'payload' object with variables from the finding record.
            // The fields which can be used are fields within the sn_se_finding table.
      
            payload.short_description = "Story generated from finding - " + grFinding.getDisplayValue();
            payload.description = "Definition: " + grFinding.definition.short_description;
            payload.description += "\nFinding details: " + grFinding.getValue('finding_details');
            payload.description += "\nFinding URL: " + gs.getProperty("glide.servlet.uri") + grFinding.getLink(false);
      }

      isDestinationtrue の場合、スクリプトはターゲットインスタンスでのみ実行されます。このブロックを使用して、 ペイロード オブジェクト値をストーリーテーブルまたはタスクテーブルのフィールドに適用します。grTask.insert() が呼び出され、レコードが作成されていることを確認します。rm_storyを選択した場合、使用可能なフィールドはrm_storyテーブルのフィールドです。

      if (isDestination) {
            // This logic is ONLY executed on the TARGET instance.
            // Set the field values in the Story/Task table using the payload object.
            // The fields which can be used are fields within the Story table.
            // If you selected rm_story, the fields you can set are those of the rm_story table.
      
            grTask.short_description = payload.short_description;
            grTask.description = payload.description;
            grTask.insert();
      }

      ソースと宛先の両方の処理を示す完全な例を次に示します。

      // Available variables
      // isSource      - True when on source instance (dev)
      // isDestination - True when on destination instance (prod)
      // payload       - The user-defined variable used to pass information between instances
      // grFinding     - The GlideRecord of the finding sending the request (source only)
      // grTask        - The GlideRecord being created on the destination instance (destination only)
      
      // Source processing and payload preparation
      if (isSource) {
            payload.short_description = "Story generated from finding - " + grFinding.getDisplayValue();
            payload.description = "Definition: " + grFinding.definition.short_description;
            payload.description += "\nFinding details: " + grFinding.getValue('finding_details');
            payload.description += "\nFinding URL: " + gs.getProperty("glide.servlet.uri") + grFinding.getLink(false);
      }
      
      // Destination processing and payload use
      // Make sure to include grTask.insert() so that the record is created
      if (isDestination) {
            grTask.short_description = payload.short_description;
            grTask.description = payload.description;
            grTask.insert();
      }
    4. インスタンスが検証され、マッピングが完了すると、顧客は結果を選択してターゲットインスタンスにプッシュできるようになります。