GlideRecord 変数を null に設定

  • リリースバージョン: Yokohama
  • 更新日 2025年01月30日
  • 所要時間:1分
  • GlideRecord 変数 (current を含む) は、データベース内での初期状態は null です。これらを空の文字列、スペース、または JavaScript null 値に戻しても、この初期状態には戻りません。

    注:
    この機能を使用するには、JavaScript のナレッジが必要です。

    初期状態に設定を戻すには、値を「NULL」に設定します。update() 関数は、現在のオブジェクトではなくレコードで実行されることに注意してください。オブジェクトは、レコードから再度呼び出されるまで初期値を表示します。

    注:
    ここで説明する機能には、admin ロールが必要です。

    例 1

    var grIncident = new GlideRecord('incident');
    grIncident.addNotNullQuery("assigned_to");
    grIncident.query();
    if (grIncident.next()) {
      gs.log(“The incident record that is going to be updated is “ + grIncident.number);
      gs.log("Previous Value of 'Assigned To' field: " + grIncident.assigned_to);
      grIncident.assigned_to = "NULL";
      grIncident.update();
      gs.log("Current Value of 'Assigned To' field: " + grIncident.assigned_to);
    }

    例 2 (ビジネスルール)

    current.u_affected_value = 'NULL';
    current.update();