GlideElement - グローバル

  • リリースバージョン: Yokohama
  • 更新日 2025年01月30日
  • 所要時間:62分
  • GlideElement API には、フィールドとその値を扱うための便利なスクリプトメソッドが多数用意されています。GlideElement メソッドは、現在の Glide レコードのフィールドで使用できます。

    GlideElement - canCreate()

    ユーザーのロールが関連するフィールドへの新しいエントリの作成を許可するかどうかを決定します。

    表 : 1. パラメーター
    名前 タイプ 説明
    なし
    表 : 2. 戻り値
    タイプ 説明
    ブール 現在のユーザーが、関連付けられたフィールドに新しいエントリを作成する権限を持っているかどうかを示すフラグ。
    可能な値:
    • true:ユーザーは新しいエントリを作成できます。
    • false:ユーザーは新しいエントリを作成できません。

    次の例は、ユーザーが問題 [problem] テーブルの最新の 3 つのレコードのエントリーを作成する権限を持っているかどうかを判断する方法を示しています。

    var gr = new GlideRecord('problem');
    
    // Get records in new state in Problem Table
    gr.addQuery('state','101');
    
    // Sort records in order of recent to earlier Created Date
    gr.orderByDesc('sys_created_on');
    
    // Limit the query to three records
    gr.setLimit(3); 
    gr.query();
    
    while(gr.next()){
      if(gr.short_description.canCreate()){ ///check to see if the current user is allowed to create the record
      gs.info("I can create new records for the field Problem statement for - " + gr.number);
      }
    }

    出力:

    I can create new records for the field Problem statement for - PRB0000004
    I can create new records for the field Problem statement for - PRB0001000
    I can create new records for the field Problem statement for - PRB0001001

    スコープ対象と同等のもの

    スコープ対象のアプリケーションで canCreate() メソッドを使用するには、対応するスコープ対象のメソッドである canCreate() を使用します。

    GlideElement - canRead()

    ユーザーのロールが関連する GlideRecord の読み取りを許可されているかどうかを決定します。

    表 : 3. パラメーター
    名前 タイプ 説明
    なし
    表 : 4. 戻り値
    タイプ 説明
    ブール フィールドが読み取れる場合は true、それ以外の場合は false。

    次の例は、読み取り可能な [簡単な説明] フィールドを含むアクティブなインシデントレコードのリストを取得する方法を示しています。

    var grIncident = new GlideRecord('incident');
    grIncident.addEncodedQuery("active=true"); //Query the Incident table for active incidents
    grIncident.orderByDesc('number');
    grIncident.setLimit(3); // limit to three results for example
    grIncident.query();
    
    while (grIncident.next()) {
        if (grIncident.short_description.canRead()) { //check to see if the current user is allowed to read the record
            gs.info('You have permission to read the short description of: ' + grIncident.number + ' ' + grIncident.short_description);
        }
    }

    出力:

    *** Script: You have permission to read the short description of: INC0009009 Unable to access the shared folder.
    *** Script: You have permission to read the short description of: INC0009005 Email server is down.
    *** Script: You have permission to read the short description of: INC0009001 Unable to post content on a Wiki page

    スコープ対象と同等のもの

    スコープ対象のアプリケーションで canRead() メソッドを使用するには、対応するスコープ対象のメソッドである canRead() を使用します。

    GlideElement:canWrite()

    ユーザーのロールが関連する GlideRecord への書き込みを許可されているかどうかを決定します。

    表 : 5. パラメーター
    名前 タイプ 説明
    なし
    表 : 6. 戻り値
    タイプ 説明
    ブール ユーザーがフィールドに書き込むことができる場合は true、それ以外の場合は false。

    次の例は、書き込み可能な [簡単な説明] フィールドを含むアクティブなインシデントレコードのリストを取得する方法を示しています。

    var grIncident = new GlideRecord('incident');
    grIncident.addEncodedQuery("active=true"); //Query the Incident table for active incidents
    grIncident.orderByDesc('number');
    grIncident.setLimit(3); // limit to three results for example
    grIncident.query();
    
    while (grIncident.next()) {
        if (grIncident.short_description.canWrite()) { //check to see if the current user is allowed to write to the record
            gs.info('You have permission to write to the short description of: ' + grIncident.number + ' ' + grIncident.short_description);
        }
    }

    出力:

    *** Script: You have permission to write to the short description of: INC0009009 Unable to access the shared folder.
    *** Script: You have permission to write to the short description of: INC0009005 Email server is down.
    *** Script: You have permission to write to the short description of: INC0009001 Unable to post content on a Wiki page

    スコープ対象と同等のもの

    スコープ対象のアプリケーションで canWrite() メソッドを使用するには、対応するスコープ対象のメソッドである canWrite() を使用します。

    GlideElement - changes()

    現在のフィールドが変更されているかどうかを判定します。この機能は、ジャーナルフィールドを除く利用可能なすべてのデータタイプで使用できます。

    注:
    changes() メソッドは、ACL スクリプト内ではサポートされていません。
    注:
    このメソッドを実行している GlideRecord が初期化および読み取られただけで、書き込まれていない場合、基礎となる前後の値は同じです。この場合、データストアに変更がないため、メソッドは「false」を返します。
    ビジネスルールの実行
    Now Platformは、列 (GlideElement オブジェクト) の内部以前の値を現在の値にリセットする前に、ビジネスルール (BEFORE または AFTER) を呼び出します。
    このシーケンスにより、次のアクションが有効になります。
    • <column>.changes 条件で AFTER ビジネスルールをトリガーします。
    • スクリプトセクションで前の GlideRecord オブジェクトにアクセスします。
    AFTERビジネスルールであっても、内部の以前の値がまだリセットされていないため、current.<field>.changes()true を返します。条件 current.<field>.value != previous.<field>.valuetrue を返します。
    前の値は、次のアクティビティの後にのみリセットされます。
    • データベースの更新が完了しました。
    • すべての AFTER ビジネスルールが処理されました。

    AFTER ビジネスルール内では、 change() メソッドは、更新後にルールが実行された場合でも、フィールド値が変更された場合は true を返します。

    表 : 7. パラメーター
    名前 タイプ 説明
    なし
    表 : 8. 戻り値
    タイプ 説明
    ブール フィールドが変更された場合は true、それ以外の場合は false。

    次のビジネスルールの例は、[ assigned_to ] フィールドの値が変更された場合に EventQueue にイベントを作成する方法を示しています。包括的な例については、「 Sample scripts from the change events business rule」を参照してください。

    if (!current.assigned_to.nil() && current.assigned_to.changes()) {
      gs.eventQueue('incident.assigned', current, current.assigned_to.getDisplayValue(), previous.assigned_to.getDisplayValue());
    }

    スコープ対象と同等のもの

    スコープ対象のアプリケーションで changes() メソッドを使用するには、対応するスコープ対象のメソッド changes() を使用します。

    GlideElement - changesFrom(オブジェクト値)

    現在のフィールドの前の値が指定されたオブジェクトと一致するかどうかを判定します。

    注:
    このメソッドを実行している GlideRecord が初期化および読み取られただけで、書き込まれていない場合、基礎となる前後の値は同じです。この場合、データストアに変更がないため、メソッドは「false」を返します。
    表 : 9. パラメーター
    名前 タイプ 説明
    オブジェクト 現在のフィールドの前の値と照合するオブジェクト値。
    表 : 10. 戻り値
    タイプ 説明
    ブール 前の値がパラメーターに一致する場合は true、一致しない場合は false。
    if (theState.changesTo(resolvedState)) {
      operation = 4; //Resolved
    }
    else if (theState.changesTo(closedState)) {
      operation = 11; //Resolution Accepted
    }
    else if (theState.changesFrom(resolvedState) || theState.changesFrom(closedState)) {
      operation = 10; //Re-open
    }
    else {
      operation = 6; //Update
    }

    スコープ対象と同等のもの

    スコープ対象のアプリケーションで changesFrom() メソッドを使用するには、対応するスコープ対象のメソッド changesFrom() を使用します。

    GlideElement - changesTo(オブジェクト値)

    変更後のフィールドの新しい値が指定されたオブジェクトと一致するかどうかを判定します。

    注:
    changesTo() メソッドは、ACL スクリプト内ではサポートされていません。
    注:
    このメソッドを実行している GlideRecord が初期化および読み取られただけで、書き込まれていない場合、基礎となる前後の値は同じです。この場合、データストアに変更がないため、メソッドは「false」を返します。
    表 : 11. パラメーター
    名前 タイプ 説明
    オブジェクト 現在のフィールドの新しい値と照合するオブジェクト値。
    表 : 12. 戻り値
    タイプ 説明
    ブール 新しい値がパラメーターに一致する場合は true、一致しない場合は false。
    if (theState.changesTo(resolvedState)) {
      operation = 4; //Resolved
    }
    else if (theState.changesTo(closedState)) {
      operation = 11; //Resolution Accepted
    }
    else if (theState.changesFrom(resolvedState) || theState.changesFrom(closedState)) {
      operation = 10; //Re-open
    }
    else {
      operation = 6; //Update
    }

    スコープ対象と同等のもの

    スコープ対象のアプリケーションで changesTo() メソッドを使用するには、対応するスコープ対象のメソッド changesTo() を使用します。

    GlideElement - dateNumericValue()

    期間フィールドについて、1970 年 1 月 1 日 00:00:00 GMT からのミリ秒数を返します。duration フィールドは既に GlideDateTime オブジェクトであるため、GlideDateTime オブジェクトを作成する必要はありません。

    表 : 13. パラメーター
    名前 タイプ 説明
    なし
    表 : 14. 戻り値
    タイプ 説明
    番号 1970 年 1 月 1 日 00:00:00 GMT からのミリ秒数。
    var inc = new GlideRecord('incident');
    inc.get('17c90efb13418700cc36b1422244b05d');
    gs.info(inc.calendar_duration.dateNumericValue());

    出力:98000

    スコープ対象と同等のもの

    スコープ対象のアプリケーションで dateNumericValue() メソッドを使用するには、対応するスコープ対象のメソッド dateNumericValue() を使用します。

    GlideElement - debug(オブジェクト o)

    オブジェクトをデバッグし、 setError(String) を使用してデバッグメッセージを追加します。

    表 : 15. パラメーター
    名前 タイプ 説明
    o オブジェクト デバッグするオブジェクト。
    表 : 16. 戻り値
    タイプ 説明
    なし

    GlideElement - getAttribute(文字列 attributeName)

    指定された属性の値を辞書から返します。

    属性がブール属性の場合は、 getBooleanAttribute(String) を使用して、値を文字列としてではなくブール値として取得します。

    表 : 17. パラメーター
    名前 タイプ 説明
    attributeName 文字列 属性の名前
    表 : 18. 戻り値
    タイプ 説明
    文字列 属性値
    doit();
    function doit() {
      var now_GR = new GlideRecord('sys_user');
      now_GR.query("user_name","admin");
      if (now_GR.next()) {
        gs.print("we got one");
        gs.print(now_GR.location.getAttribute("tree_picker"));
      }
     
    }

    スコープ対象と同等のもの

    スコープ対象のアプリケーションで getAttribute() メソッドを使用するには、対応するスコープ対象のメソッド getAttribute() を使用します。

    GlideElement - getBaseTableName()

    フィールドのベーステーブルを取得します。

    表 : 19. パラメーター
    名前 タイプ 説明
    なし
    表 : 20. 戻り値
    タイプ 説明
    文字列 ベーステーブルの名前。この名前は、フィールドが定義されているテーブルとは異なる場合があります。製品ドキュメントの Table extension and classes を参照してください。

    次の例は、インシデントレコードの [アサイン先グループ] フィールドのベーステーブルを作成する方法を示しています。

    var gr = new GlideRecord('incident');
    
    //query the Incident Records which have category as Inquiry/Help
    gr.addQuery('category','inquiry');
    
    // sort them in the order of earlier to recent created date
    gr.orderBy('sys_created_on');
    gr.query();
    
    if(gr.next()){ //If at least any one record exists matching this query
    
      //Print the base table for the Assignment Group field
      gs.print("The Base Table for the field Assignment Group is - " + gr.assignment_group.getBaseTableName()); 
    };

    出力:

    The Base Table for the field Assignment Group is - task

    GlideElement - getBooleanAttribute(文字列 attributeName)

    指定された属性のブール値を辞書から返します。

    値を文字列として取得するには、 getAttribute(string) を使用します。

    表 : 21. パラメーター
    名前 タイプ 説明
    attributeName 文字列 属性の名前
    表 : 22. 戻り値
    タイプ 説明
    ブール 属性のブール値。属性が存在しない場合は false を返します。

    次の例は、2 つのフィールドの ignore_filter_on_new 属性のブール値を取得する方法を示しています。

    var inc = new GlideRecord('incident');
    inc.query();
    
    if (inc.next())
     {
       // opened_by field has attribute "ignore_filter_on_new = true"
       gs.info(inc.opened_by.getBooleanAttribute("ignore_filter_on_new"));
    
      // short_description field does not have attribute ignore_filter_on_new
       gs.info(inc.short_description.getBooleanAttribute("ignore_filter_on_new"));
     }

    出力:

    true
    false

    スコープ対象と同等のもの

    スコープ対象のアプリケーションで getBooleanAttribute() メソッドを使用するには、対応するスコープ対象のメソッド getBooleanAttribute() を使用します。

    GlideElement - getChoices(文字列依存)

    フィールドの選択リストを生成します。拡張テーブルからではなく、ベーステーブルからのみ選択値を返します。

    表 : 23. パラメーター
    名前 タイプ 説明
    依存 文字列 オプション。選択リストフィールドが依存する関連レコード内のフィールド。
    表 : 24. 戻り値
    タイプ 説明
    アレイリスト フィールドの選択値。
    var glideRecord = new GlideRecord('incident'); 
    glideRecord.query('priority','1'); 
    glideRecord.next(); 
     
    // urgency has choice list: 1 - High, 2 - Medium, 3 - Low, with value: 1, 2, 3
    var choices = glideRecord.urgency.getChoices();

    スコープ対象と同等のもの

    スコープ対象のアプリケーションで getChoices() メソッドを使用するには、対応するスコープ対象のメソッド getChoices() を使用します。

    GlideElement - getChoiceValue()

    現在の選択値の選択ラベルを取得します。

    表 : 25. パラメーター
    名前 タイプ 説明
    なし
    表 : 26. 戻り値
    タイプ 説明
    文字列 選択肢ラベル。

    次の例は、優先度の値が「標準」の変更要求レコードの選択ラベルを取得する方法を示しています。

    var gr = new GlideRecord('change_request');
    
    //query for the change records with change type as "Normal"
    gr.addQuery('type','normal');
    
    // sort them in the order of recent to earlier Created Date
    gr.orderByDesc('sys_created_on'); 
    
    // limit the query to 4 records
    gr.setLimit(4); 
    gr.query();
    
    while(gr.next()){
     //Printing the choice label for those records
     gs.print("The label of the current priority '"+ gr.priority+"' for the change request - " + gr.number + " is - "+ gr.priority.getChoiceValue()); 
    }

    出力:

    The label of the current priority '4' for the change request - CHG0000014 is - 4 - Low
    The label of the current priority '4' for the change request - CHG0000013 is - 4 - Low
    The label of the current priority '4' for the change request - CHG0000012 is - 4 - Low
    The label of the current priority '4' for the change request - CHG0000011 is - 4 - Low

    スコープ対象と同等のもの

    スコープ対象のアプリケーションで getChoiceValue() メソッドを使用するには、対応するスコープ対象のメソッド getChoiceValue() を使用します。

    GlideElement - getDebugCount()

    debug() によってログに記録されたデバッグメッセージの数を取得します。

    表 : 27. パラメーター
    名前 タイプ 説明
    なし
    表 : 28. 戻り値
    タイプ 説明
    番号 デバッグメッセージの数。

    GlideElement - getDependent()

    指定したフィールドが依存しているフィールド (要素) を返します。

    表 : 29. パラメーター
    名前 タイプ 説明
    なし
    表 : 30. 戻り値
    タイプ 説明
    文字列 現在のフィールドが依存するフィールドの名前。依存関係がない場合は null。

    次の例は、 getDependent() メソッドを使用して構成アイテムフィールドの親フィールドを検索する方法を示しています。

    var inc_gr = new GlideRecord('incident');
    inc_gr.get('985f53d82fab301032e8808cf699b6e8'); // Get a particular Incident
    
    var field_element = inc_gr.getElement('cmdb_ci'); // Get the Configuration Item element
    var dependent_field = field_element.getDependent(); // Read the dependent field
    gs.info("Dependent field: " + dependent_field);
    if(dependent_field)
      {
        var dependent_field_value = inc_gr.getValue(dependent_field);  
        if(!dependent_field_value)
          {
            var base_table = field_element.getRefRecord(); // Retrieve the reference record
            var dependent_field_value = base_table.getValue(dependent_field); // Read the parent field value
          }
        inc_gr.setValue(dependent_field, dependent_field_value); // Update the parent field on the Incident
        inc_gr.update();
      }

    出力:

    company

    GlideElement - getDependentTable()

    現在のテーブルが依存しているテーブルを取得します。

    表 : 31. パラメーター
    名前 タイプ 説明
    なし
    表 : 32. 戻り値
    タイプ 説明
    文字列 テーブルの名前。

    GlideElement - getDisplayValue(数値 maxChar)

    フィールドの書式設定された表示値を返します。

    表示値は、データベースの実際の値とユーザーまたはシステムの設定と設定に基づいて操作されます。

    返される表示値は、フィールドタイプによって異なります。
    • 選択肢フィールド:データベース値は数値でもかまいませんが、表示値はよりわかりやすいものになります。
    • 日付フィールド:データベース値は UTC 形式で、表示値はユーザーのタイムゾーンに基づいています。
    • 暗号化テキスト:データベース値は暗号化されますが、表示される値はユーザーの暗号化コンテキストに基づいて暗号化されません。
    • 参照フィールド:データベース値はsys_idですが、表示値は参照レコードの表示フィールドです。
    表 : 33. パラメーター
    名前 タイプ 説明
    maxChar 番号 オプション。返す最大文字数。
    表 : 34. 戻り値
    タイプ 説明
    文字列 フィールドの表示値。
    var fields = current.getFields();
    for (var i = 0; i < fields.size(); i++) { 
      var field = fields.get(i);
      var name = field.getName(); 
      var value = field.getDisplayValue(); 
      gs.print(i + ". " + name + "=" + value); 
    }

    スコープ対象と同等のもの

    スコープ対象のアプリケーションで getDisplayValue() メソッドを使用するには、対応するスコープ対象のメソッド getDisplayValue() を使用します。

    GlideElement - getDisplayValueExt(Number maxChar, String nullSub)

    フィールドの書式設定された表示値を返します。表示値が null または空の場合は、指定された代替値を返します。

    表示値は、データベースの実際の値とユーザーまたはシステムの設定と設定に基づいて操作されます。

    返される表示値は、フィールドタイプによって異なります。
    • 選択肢フィールド:データベース値は数値でもかまいませんが、表示値はよりわかりやすいものになります。
    • 日付フィールド:データベース値は UTC 形式で、表示値はユーザーのタイムゾーンに基づいています。
    • 暗号化テキスト:データベース値は暗号化されますが、表示される値はユーザーの暗号化コンテキストに基づいて暗号化されません。
    • 参照フィールド:データベース値はsys_idですが、表示値は参照レコードの表示フィールドです。
    表 : 35. パラメーター
    名前 タイプ 説明
    maxChar 番号 オプション。返される最大文字数。

    デフォルト:すべて

    nullSub 文字列 表示値が null または空の場合に返される値。
    表 : 36. 戻り値
    タイプ 説明
    文字列 フィールドの書式設定された表示値、または指定された代替値。

    次の例は、インシデント [incident] テーブルに最新の 2 つのアクティブなレコードを表示する方法を示しています。

    var gr = new GlideRecord('incident');
    gr.addQuery('active', true);      // get the active records
    gr.orderByDesc('sys_updated_on'); // sort the records from most recent to oldest updated date
    gr.setLimit(2);                   // limit the query to 2 records
    gr.query();
    
    while(gr.next()){ // Printing the Display Value of the Configuration Item field. 
      // If the Display Value is Null/Empty, then it will be substituted with Default value "I with Null/Empty Display Value"
      gs.info("The Display Value of the Configuration Item for the incident - "+ gr.number+ " is " + gr.cmdb_ci.getDisplayValueExt(40, " CI with Null/Empty Display Value"));
    }

    出力:

    The Display Value of the Configuration Item for the incident - INC0007001 is  CI with Null/Empty Display Value
    The Display Value of the Configuration Item for the incident - INC0000069 is NYC RAC

    GlideElement - getDisplayValueLang(文字列言語)

    パラメーターとして渡された言語でフィールドの表示値を取得します。

    結果は、[ 選択肢]、[ 翻訳済みフィールド]、[ 翻訳済みテキスト] などの翻訳可能なフィールドタイプにのみ適用されます。その他のフィールドタイプの場合、結果のデフォルトは getDisplayValue() です。

    翻訳された値を取得するには、対応する言語プラグインが必要です。詳細については、「Activate a language」を参照してください。

    スコープ付き GlideElement - getLabelLang(文字列言語)」も参照してください。

    表 : 37. パラメーター
    名前 タイプ 説明
    language 文字列 IETF BCP-47 に準拠した言語タグ。
    表 : 38. 戻り値
    タイプ 説明
    文字列 渡された言語でのフィールドの表示値。翻訳が利用できない場合、メソッドは現在のユーザーの言語に翻訳された値を取得します。翻訳が利用できない場合、結果はデフォルトで英語になります。

    次の例は、[ 承認 (UI ビュー)] タイトルフィールドから原文とドイツ語に翻訳されたテキストを取得する方法を示しています。

    var uiView = new GlideRecord("sys_ui_view");
    uiView.get("fa776f6d97700100f309124eda2975bc");
    
    gs.info("getDisplayValue: " + uiView.getElement("title").getDisplayValue());
    gs.info("getDisplayValueLang: " + uiView.getElement("title").getDisplayValueLang("de"));

    出力:

    getDisplayValue: Accept
    getDisplayValueLang: Akzeptieren

    スコープ対象と同等のもの

    スコープ対象のアプリケーションで getDisplayValueLang() メソッドを使用するには、対応するスコープ対象のメソッド getDisplayValueLang() を使用します。

    GlideElement - getED()

    フィールド内のデータではなく、特定のフィールドに関する情報を提供する要素記述子を返します。

    表 : 39. パラメーター
    名前 タイプ 説明
    なし
    表 : 40. 戻り値
    タイプ 説明
    ElementDescriptor フィールドの要素記述子。

    この例では、現在のレコードのフィールドとフィールド記述子を取得します。

    var fields = current.getFields();
    for (i=0; i<fields.size(); i++) { 
      var field = fields.get(i);
      var descriptor = field.getED(); 
      gs.print("type=" + descriptor.getType() + 
        " internalType=" + descriptor.getInternalType()); 
    }

    スコープ対象と同等のもの

    スコープ対象のアプリケーションで getED() メソッドを使用するには、対応するスコープ対象のメソッド getED() を使用します。

    GlideElement - getElementValue(文字列値)

    指定された要素の値を返します。

    表 : 41. パラメーター
    名前 タイプ 説明
    文字列 値を返す要素。
    表 : 42. 戻り値
    タイプ 説明
    文字列 要素の値。
    var fields = current.getFields();
    for (var i = 0; i < fields.size(); i++) {
      var field = fields.get(i);
      var name = field.getName();
    
      // Returns the unformatted value of the element
      var value = field.getElementValue(name);
      var disValue = field.getDisplayValue();
      gs.print(i + ". " + name + " = " + value + ' display value = ' + disValue);
    }

    出力

    1. cmdb_ci = 109562a3c611227500a7b7ff98cc0dc7 display value = Storage Area Network 001
    2. impact = 2 display value = 2 - Medium

    GlideElement - getError()

    指定された要素に関連付けられているエラーメッセージを返します。

    setError() メソッドを使用して、特定のフィールド (要素) にエラーを設定します。

    表 : 43. パラメーター
    名前 タイプ 説明
    なし
    表 : 44. 戻り値
    タイプ 説明
    文字列 指定された要素に現在設定されているエラーメッセージ。

    この例では、short_description要素にエラーを設定し、そのエラーを読み戻す方法を示します。

    var incidentGR = new GlideRecord('incident');
    incidentGR.setLimit(1);
    incidentGR.query();
    if (incidentGR.next()) {
        incidentGR.short_description.setError('The description is too short.');
        gs.info(incidentGR.short_description.getError()); // 'The description is too short.'
    }

    出力:

    The description is too short.

    この例では、関数呼び出しで getError() を使用する方法を示します。

    // Before query business rule (order = 100)
    (function executeRule(current, previous /*null when async*/) {
        var shortDescription = current.getValue('short_description');
        if (shortDescription.length < 10) {
            current.short_description.setError('The description is too short.');
            current.setAbortAction(true);
        }
    })(current, previous);
    
    // Before query business rule (order = 200)
    (function executeRule(current, previous /*null when async*/) {
        var shortDescriptionErrMsg = current.short_description.getError();
        if (shortDescriptionErrMsg) {
            // Some error was set in one of the previous business rules.
        }
    })(current, previous);

    GlideElement - getEscapedValue()

    現在の要素のエスケープされた値を取得します。

    表 : 45. パラメーター
    名前 タイプ 説明
    なし
    表 : 46. 戻り値
    タイプ 説明
    文字列 現在の要素のエスケープされた値。

    次の例は、 getEscapedValue() メソッドを使用して、インシデントの簡単な説明フィールドの内容をエスケープ文字付きで表示する方法を示しています。

    /*** Overview - Update incident short description with escape characters and printing ***/
    var inc = new GlideRecord('incident');
    inc.query();
    inc.next();
    inc.short_description = 'Can\'t log into SAP from my laptop today'; 
    inc.update();
    gs.info("Short Description: "+inc.getElement('short_description').toString()); //without escape characters
    gs.info("Escaped Short Description: "+inc.getElement('short_description').getEscapedValue()); // with escape characters

    出力:

    Short Description: Can't log into SAP from my laptop today
    Escaped Short Description: Can\'t log into SAP from my laptop today

    GlideElement - getFieldStyle()

    フィールドの CSS スタイルを取得します。

    表 : 47. パラメーター
    名前 タイプ 説明
    なし
    表 : 48. 戻り値
    タイプ 説明
    文字列 フィールドの CSS スタイル。
    var fields = current.getFields();
    for (var i = 0; i < fields.size(); i++) { 
      var field = fields.get(i);
      var css_style = field.getFieldStyle();  
      gs.print("CSS style" + "=" + css_style); 
    }

    GlideElement:getGlideObject()

    Glide オブジェクトを取得します。

    表 : 49. パラメーター
    名前 タイプ 説明
    なし
    表 : 50. 戻り値
    タイプ 説明
    オブジェクト Glide オブジェクト。
    function calcDateDelta(start, end, calendar) {
      var cal = GlideCalendar.getCalendar(calendar);
      if (!cal.isValid())
          return null;
      var realStart = start.getGlideObject();
      var realEnd = end.getGlideObject();  
      var duration = cal.subtract(realStart, realEnd);
      return duration;
    }

    GlideElement - getGlideRecord()

    Glide レコードを取得します。

    表 : 51. パラメーター
    名前 タイプ 説明
    なし
    表 : 52. 戻り値
    タイプ 説明
    GlideRecord Glide レコードオブジェクト。
    var grInc = new GlideRecord('incident');
    grInc.get('sys_id','ef43c6d40a0a0b5700c77f9bf387afe3');
    gs.info("Initial grInc - " + grInc.getDisplayValue());
    
    var caller = grInc.getElement("caller_id");
    doit(caller);
    
    function doit(caller) {
      var now_GR = caller.getGlideRecord();
      gs.info("doit gr is - " + now_GR.getDisplayValue());
    }

    出力

    *** Script: Initial grInc - INC0000050
    *** Script: doit gr is - INC0000050

    GlideElement - getHTMLValue(Number maxChars)

    フィールドの HTML 値を返します。

    表 : 53. パラメーター
    名前 タイプ 説明
    maxChar 番号 オプション。返す最大文字数。
    表 : 54. 戻り値
    タイプ 説明
    文字列 フィールドの HTML 値。

    次の例は、会議メモの HTML コンテンツを取得する方法を示しています。

    /*
      getHTMLValueExt() This Function is used to get HTML Value of a field. It accepts 2 Parameters
    
    a. maxChar- Number - The maximum number of characters to return.
    b. nullSub - String - The value to return if the HTML value is null or empty.
    
    */
    
    
    // get a cab meeting record by its sys_id
    var gr = new GlideRecord('cab_meeting');
    gr.addQuery('sys_id','7777777b6d2a20100sys70id534330f6');
    gr.query();
    
    if(gr.next()){
      var substituteString = 'Meeting Notes Unavailable';
      var maxLength = 50;
      gs.print(gr.meeting_notes.getHTMLValueExt(maxLength, substituteString));
    }

    スコープ対象と同等のもの

    スコープ対象のアプリケーションで getHTMLValue() メソッドを使用するには、対応するスコープ対象のメソッド getHTMLValue() を使用します。

    GlideElement - getHTMLValueExt(数値 maxChar, 文字列 nullSub)

    フィールドの HTML 値を返すか、HTML 値が null または空の場合は指定された代替値を返します。

    表 : 55. パラメーター
    名前 タイプ 説明
    maxChar 番号 返す最大文字数。
    nullSub 文字列 HTML 値が null または空の場合に返される値。
    表 : 56. 戻り値
    タイプ 説明
    文字列 HTML 値または指定された代替値。

    次の例は、会議メモの HTML コンテンツを取得する方法を示しています。

    // get a cab meeting record by its sys_id
    var gr = new GlideRecord('cab_meeting');
    gr.addQuery('sys_id','7777777b6d2a20100sys70id534330f6');
    gr.query();
    
    if(gr.next()){
      var substituteString = 'Meeting Notes Unavailable';
      var maxLength = 50;
      gs.print(gr.meeting_notes.getHTMLValueExt(maxLength, substituteString));
    }
    選択したレコードの会議メモが空でない場合の出力:
    <p>Meeting note content.</p>

    GlideElement - getJournalEntry(Number mostRecent)

    最新のジャーナルエントリまたはすべてのジャーナルエントリを返します。

    表 : 57. パラメーター
    名前 タイプ 説明
    mostRecent 番号 1 の場合、最新のエントリを返します。-1 の場合、すべてのジャーナルエントリが返されます。
    表 : 58. 戻り値
    タイプ 説明
    文字列

    最新のエントリの場合、ジャーナルエントリのフィールドラベル、タイムスタンプ、およびユーザー表示名を含む文字列を返します。

    すべてのジャーナルエントリについて、単一の文字列として入力されたすべてのジャーナルエントリについて同じ情報を返し、各エントリは「\n\n」で区切られます。

    //gets all journal entries as a string where each entry is delimited by '\n\n'
    var notes = current.work_notes.getJournalEntry(-1); 
    //stores each entry into an array of strings
    var na = notes.split("\n\n");  
                          
    for (var i = 0; i < na.length; i++)                 
      gs.print(na[i]);

    スコープ対象と同等のもの

    スコープ対象のアプリケーションで getJournalEntry() メソッドを使用するには、対応するスコープ対象のメソッド getJournalEntry() を使用します。

    GlideElement - getLabel()

    オブジェクトのラベルを返します。

    表 : 59. パラメーター
    名前 タイプ 説明
    なし
    表 : 60. 戻り値
    タイプ 説明
    文字列 オブジェクトのラベル
    var now_GR = new GlideRecord("sc_req_item");
    now_GR.addQuery("request", current.sysapproval);
    now_GR.query();
    while(now_GR.next()) {
        var nicePrice = now_GR.price.toString();
        if (nicePrice != ) {
            nicePrice = parseFloat(nicePrice);
            nicePrice = nicePrice.toFixed(2);
        }
        template.print(now_GR.number + ":  " + now_GR.quantity + " X " + now_GR.cat_item.getDisplayValue() + " at $" + nicePrice + " each \n");
        template.print("    Options:\n");
        var variables = now_GR.variables.getElements();    
        for (var key in variables) {
          var now_V = variables[key];
          if(now_V.getQuestion().getLabel() != ) {
             template.space(4);
             template.print('     ' +  now_V.getQuestion().getLabel() + " = " + now_V.getDisplayValue() + "\n");  
          }
        }
    }

    スコープ対象と同等のもの

    スコープ対象のアプリケーションで getLabel() メソッドを使用するには、対応するスコープ対象のメソッド getLabel() を使用します。

    GlideElement - getLabelLang(文字列言語)

    パラメーターとして渡された言語のフィールドのラベル値を取得します。

    翻訳された値を取得するには、対応する言語プラグインが必要です。詳細については、「Activate a language」を参照してください。

    表 : 61. パラメーター
    名前 タイプ 説明
    language 文字列 IETF BCP-47 に準拠した言語タグ。
    表 : 62. 戻り値
    タイプ 説明
    文字列 渡された言語のフィールドラベルの値。 翻訳が利用できない場合、メソッドは現在のユーザーの言語に翻訳された値を取得します。翻訳が利用できない場合、結果はデフォルトで英語になります。

    次の例は、元のラベルテキストと 、承認 (UI ビュー) タイトルのドイツ語訳を取得する方法を示しています。

    var uiView = new GlideRecord("sys_ui_view");
    uiView.get("fa776f6d97700100f309124eda2975bc");
    
    gs.info("getLabel: " + uiView.getElement("title").getLabel());
    gs.info("getLabelLang: " + uiView.getElement("title").getLabelLang("de"));

    出力:

    getLabel: Title
    getLabelLang: Titel

    スコープ対象と同等のもの

    スコープ対象のアプリケーションで getLabelLang() メソッドを使用するには、対応するスコープ対象のメソッド getLabelLang() を使用します。

    GlideElement - getName()

    フィールドの名前を返します。

    表 : 63. パラメーター
    名前 タイプ 説明
    なし
    表 : 64. 戻り値
    タイプ 説明
    文字列 フィールド名。

    次の例は、sys_userレコード内の各フィールドの名前とその他の値を取得する方法を示しています。

    var userRec = new GlideRecord("sys_user"); // GlideRecord to sys_user table
    
    userRec.get("5137153cc611227c000bbd1bd8cd2005"); // Sys Id of user: Fred Luddy
    
    var fields = userRec.getFields();
    
    for (var i = 0; i < fields.size(); i++) {
    
        var field = fields.get(i);
        var name = field.getName(); // Name of the field
        var label = field.getLabel(); // Label of the field
        var value = field.getDisplayValue(); // Value of the field
    
        gs.info((Number(i) + 1) + ".\n" + "Field Label: " + label + "\n" + "Field Name: " + name + "\n" + "Field Value: " + value);
    
    };

    出力。結果には 62 個のフィールドが含まれており、スペースを節約するために省略記号 (...) で切り捨てられています。

    *** Script: 1.
    Field Label: Country code
    Field Name: country
    Field Value: 
    *** Script: 2.
    Field Label: Calendar integration
    Field Name: calendar_integration
    Field Value: Outlook
    ...
    *** Script: 47.
    Field Label: First name
    Field Name: first_name
    Field Value: Fred
    ...
    *** Script: 54.
    Field Label: Last name
    Field Name: last_name
    Field Value: Luddy
    ...

    スコープ対象と同等のもの

    スコープ対象のアプリケーションで getName() メソッドを使用するには、対応するスコープ対象のメソッド getName() を使用します。

    GlideElement - getRefRecord()

    指定された参照要素の GlideRecord オブジェクトを返します。

    計算されたフィールドの場合、このメソッドは参照レコードをフェッチし、スクリプト化されたデフォルト値で計算を実行します。

    警告:
    参照要素に値が含まれていない場合は、NULL オブジェクトではなく空の GlideRecord オブジェクトが返されます。
    表 : 65. パラメーター
    名前 タイプ 説明
    なし
    表 : 66. 戻り値
    タイプ 説明
    GlideRecord GlideRecord オブジェクト
    
    var grINC = new GlideRecord('incident'); 
    grINC.notNullQuery('caller_id'); 
    grINC.query(); 
    if (grINC.next()) { 
    
    // Get a GlideRecord object for the referenced sys_user record 
    var grUSER = grINC.caller_id.getRefRecord(); 
    if (grUSER.isValidRecord()) 
      gs.print( grUSER.getValue('name') ); 
    
    } 

    スコープ対象と同等のもの

    スコープ対象のアプリケーションで getRefRecord() メソッドを使用するには、対応するスコープ対象のメソッド getRefRecord() を使用します。

    GlideElement - getStyle()

    値の CSS スタイルを取得します。

    表 : 67. パラメーター
    名前 タイプ 説明
    なし
    表 : 68. 戻り値
    タイプ 説明
    文字列 値の CSS スタイル。
    // Get string of style field from Field Style record
    var cssStyle = now_GR.state.getStyle();

    GlideElement - getTableName()

    フィールドのテーブルの名前を返します。

    表 : 69. パラメーター
    名前 タイプ 説明
    なし
    表 : 70. 戻り値
    タイプ 説明
    文字列 テーブルの名前。これは、レコードが含まれているテーブルクラスとは異なる場合があります。製品ドキュメントの「テーブルとクラス」を参照してください。
    if (current.approver.getTableName() == "sysapproval_approver") {
      if (current.approver == email.from_sys_id)  {
         current.comments = "reply from: " + email.from + "\n\n" + email.body_text;
     
       // if it's been cancelled, it's cancelled.
      var doit = true;
      if (current.state=='cancelled')
          doit = false;
     
      if (email.body.state != undefined)
         current.state= email.body.state;
     
       if (doit)
          current.update();
    } else {
       gs.log("Approval for task ("+current.sysapproval.getDisplayValue()+") rejected because user sending 
               email( "+email.from+") does not match the approver ("+current.approver.getDisplayValue()+")");
    }
     
    }

    スコープ対象と同等のもの

    スコープ対象のアプリケーションで getTableName() メソッドを使用するには、対応するスコープ対象のメソッド getTableName() を使用します。

    GlideElement - getTextAreaDisplayValue()

    関連付けられたフィールドの表示値を取得し、HTML をエスケープします。

    表 : 71. パラメーター
    名前 タイプ 説明
    なし
    表 : 72. 戻り値
    タイプ 説明
    文字列 関連付けられたフィールドのエスケープされた 表示値 の HTML。

    次の例では、KB 記事の表示値を取得します。

    var grh = new GlideRecord('kb_knowledge');
    grh.get('c85cd2519f77230088aebde8132e70c2');  // Knowledge record sys_id
    var t = grh.text.getTextAreaDisplayValue(); // Text is HTML type field
    var d = GlideXMLUtil.parseHTML(t); // Parse the HTML
    var b = d.getDocumentElement().getTextContent().trim();
    gs.info(b);

    出力:

    This article explains how to use automatic replies in Outlook 2010 for Exchange accounts.
    
    Setting Up Automatic Replies
    
    Click the 
    File tab.
    Click 
    Automatic Replies.
    Select 
    Send automatic replies.
    If desired, select the 
    Only send during this time range check box to schedule when your out of office replies are active. If you do not specify a start and end time, auto-replies will be sent until you select the
     Do not send automatic replies check box.
    On the 
    Inside My Organization tab, type the response that you want to send to colleagues while you are out of the office.
    On the 
    Outside My Organization tab, select the 
    Auto-reply to people outside my organization check box, and then type the response that you want to send while you are out of the office. Select whether you want replies sent to 
    My contacts only or to 
    Anyone outside my organization who sends you messages.
    
    NOTE:
    If you select 
    My Contacts only in step 6, replies will be sent 
    only to contacts that exist in your Contacts folder.
    
    
    
    Using Rules With Automatic Replies
    It is also possible to use rules to manage your messages while you are out of office. For example, you can create rules to automatically move or copy messages to other folders, to delete messages, to send custom replies, and so on.
    
    Click the 
    File tab.
    Click 
    Automatic Replies.
    Click 
    Rules, and then click 
    Add Rule.
    Under 
    When a message arrives that meets the following conditions, specify the conditions that the message must meet for the rule to be applied. If you want to specify more conditions, click 
    Advanced, enter or select the options that you want, and then click 
    OK.
    If you want to specify that this rule must be applied last, select the 
    Do not process subsequent rules check box.
    Under 
    Perform these actions, select the actions that you want. You can select more than one action.
    Click 
    OK three times.
    
    NOTES:
    
    Automatic Replies rules can also be edited by following the above procedure.
    To turn Automatic Replies rules on or off, in the Automatic Reply Rules dialog box, select or clear the check box of the rule that you want to turn on or off.
    

    GlideElement - getValue()

    データベース内のフィールドの値を返します。

    表 : 73. パラメーター
    名前 タイプ 説明
    なし
    表 : 74. 戻り値
    タイプ 説明
    文字列 フィールドの値。

    次の例では、データベース内の指定されたフィールドの値を取得します。

    var now_GR = new GlideRecord('incident');
    now_GR.get('9c573169c611228700193229fff72400'); //INC0000001
    gs.info('Display Values');
    gs.info('Opened at ' + now_GR.opened_at.getDisplayValue());
    gs.info('Opened by ' + now_GR.opened_by.getDisplayValue());
    gs.info('Priority ' + now_GR.priority.getDisplayValue());
    gs.info('Values');
    gs.info('Opened at ' + now_GR.opened_at.getValue());
    gs.info('Opened by ' + now_GR.opened_by.getValue());
    gs.info('Priority ' + now_GR.priority.getValue());
    

    出力:

    Display Values
    Opened at 2022-02-01 15:09:51
    Opened by Joe Employee
    Priority 1 - Critical
    Values
    Opened at 2022-02-01 23:09:51
    Opened by 681ccaf9c0a8016400b98a06818d57c7
    Priority 1
    

    スコープ対象と同等のもの

    スコープ対象のアプリケーションで getValue() メソッドを使用するには、対応するスコープ対象のメソッド スコープ付き GlideElement - getValue() を使用します。

    GlideElement - getXHTMLValue()

    フィールドの XHTML 値を取得します。

    表 : 75. パラメーター
    名前 タイプ 説明
    なし
    表 : 76. 戻り値
    タイプ 説明
    文字列 XHTML 値

    GlideElement - getXMLValue()

    フィールドの XML 値を文字列として取得します。

    表 : 77. パラメーター
    名前 タイプ 説明
    なし
    表 : 78. 戻り値
    タイプ 説明
    文字列 XML 値

    GlideElement - hasAttribute(文字列 attributeName)

    フィールドに特定の属性があるかどうかを判定します。

    表 : 79. パラメーター
    名前 タイプ 説明
    attributeName 文字列 チェックする属性
    表 : 80. 戻り値
    タイプ 説明
    ブール フィールドに属性がある場合は true、それ以外の場合は false。
    var totalCritical = 0;
     
    var filledCritical = 0; var fields = current.getFields(); gs.print(fields); for (var num = 0; num < fields.size(); num++) { 
     
        gs.print("RUNNING ARRAY VALUE " + num);
       var ed = fields.get(num).getED();
       if(ed.hasAttribute("tiaa_critical")) {
           gs.print("CRITICAL FIELD FOUND");
           totalCritical ++;
           if (!fields.get(num).isNil()) {
               filledCritical ++;
           }
       }
     
    } var answer = 0; gs.print("TOTAL - " + totalCritical); gs.print("FILLED - " + filledCritical); if (filledCritical > 0 && totalCritical > 0){ 
     
        var pcnt = (filledCritical/totalCritical)*100;
       answer = pcnt.toFixed(2);;    
     
    } answer;

    GlideElement - hasRightsTo(文字列 operationName)

    ユーザーに特定の操作を実行する権限があるかどうかを決定します。

    表 : 81. パラメーター
    名前 タイプ 説明
    operationName 文字列 チェックする操作の名前
    表 : 82. 戻り値
    タイプ 説明
    ブール ユーザーに操作を実行する権限がある場合は true、それ以外の場合は false。

    ユーザーに操作を実行する権限があるかどうかを示すフラグ。

    有効な値:
    • true:ユーザーには権限があります。
    • false:ユーザーには権限がありません。

    次の例は、ユーザーが特定のテーブルを読み取る権限を持っているかどうかを判断する方法を示しています。

    // Pass table name and userId to check if user has read access against given table name
    checkAccess('incident', 'adela.cervantsz');
    
    function checkAccess(tableName, userID) {
    
        var inc = new GlideRecordSecure(tableName);
        inc.get('$[sys_id]');
    
        var secureManager = GlideSecurityManager.get();
    
        //fetch a different user, using user_name field on the target user record
        var userObj = gs.getUser().getUserByID(userID); 
        secureManager.setUser(userObj);
    
        var access = 'record/incident/read';
    
        //check if user has right to access
        var canRead = secureManager.hasRightsTo(access, inc); 
        gs.info('canRead: ' + canRead);
    }

    出力:

    canRead: false

    GlideElement - hasValue()

    フィールドに値があるかどうかを判定します。

    表 : 83. パラメーター
    名前 タイプ 説明
    なし
    表 : 84. 戻り値
    タイプ 説明
    ブール フィールドに値がある場合は true、それ以外の場合は false。

    GlideElement:nil()

    フィールドが null かどうかを判定します。

    表 : 85. パラメーター
    名前 タイプ 説明
    なし
    表 : 86. 戻り値
    タイプ 説明
    ブール フィールドが null または空の文字列の場合は true、それ以外の場合は false。
    if (current.start_date.changes() || current.end_date.changes() || current.assigned_to.changes()) { 
      if (!current.start_date.nil() && !current.end_date.nil() && !current.assigned_to.nil()) {
     gs.eventQueue("change.calendar.notify", current, current.assigned_to, previous.assigned_to);
     
    }

    スコープ対象と同等のもの

    スコープ対象のアプリケーションで nil() メソッドを使用するには、対応するスコープ対象のメソッド nil() を使用します。

    GlideElement - setDateNumericValue(ミリ秒数)

    期間フィールドについて、期間フィールドを 1970 年 1 月 1 日 00:00:00 GMT からのミリ秒数に設定します。duration フィールドは既に GlideDateTime オブジェクトであるため、GlideDateTime オブジェクトを作成する必要はありません。

    表 : 87. パラメーター
    名前 タイプ 説明
    ミリ秒 番号 期間にまたがったミリ秒数。
    表 : 88. 戻り値
    タイプ 説明
    なし
    var inc = new GlideRecord('incident');
    inc.get('17c90efb13418700cc36b1422244b05d');
    var timems = inc.calendar_duration.dateNumericValue();
    timems = timems + 11*1000; 
    inc.calendar_duration.setDateNumericValue(timems)
    gs.info(inc.calendar_duration.getValue());

    出力:

    1970-01-01 00:01:38

    スコープ対象と同等のもの

    スコープ対象のアプリケーションで setDateNumericValue() メソッドを使用するには、対応するスコープ対象のメソッド setDateNumericValue() を使用します。

    GlideElement - setDisplayValue(オブジェクト displayValue)

    フィールドの表示値を設定します。

    表 : 89. パラメーター
    名前 タイプ 説明
    displayValue オブジェクト 表示する値。
    表 : 90. 戻り値
    タイプ 説明
    なし

    スコープ対象と同等のもの

    スコープ対象のアプリケーションで setDisplayValue() メソッドを使用するには、対応するスコープ対象のメソッド setDisplayValue() を使用します。

    GlideElement - setError(文字列メッセージ)

    関連するフィールド (要素) にエラーメッセージを追加します。

    getError() メソッドを使用してエラーメッセージを取得できます。

    表 : 91. パラメーター
    名前 タイプ 説明
    なし
    表 : 92. 戻り値
    タイプ 説明
    なし
    if ((!current.u_date1.nil()) && (!current.u_date2.nil())) {
      var start = current.u_date1.getGlideObject().getNumericValue();
      var end = current.u_date2.getGlideObject().getNumericValue();
      if (start > end) {
        gs.addInfoMessage('start must be before end');
        current.setAbortAction(true);
        current.u_date1.setError('start must be before end');
      }
    }

    スコープ対象と同等のもの

    スコープ対象のアプリケーションで setError() メソッドを使用するには、対応するスコープ対象のメソッド setError() を使用します。

    GlideElement - setInitialValue(オブジェクト値)

    フィールドの初期値を設定します。

    このメソッドは廃止されました。この機能には GlideElement - setValue(オブジェクト値) を使用します。

    表 : 93. パラメーター
    名前 タイプ 説明
    オブジェクト フィールドの初期値。
    表 : 94. 戻り値
    タイプ 説明
    なし

    GlideElement - setJournalEntry(String entry, String userName)

    ジャーナルエントリと作成者を作業メモまたはコメントフィールドとして追加します。

    表 : 95. パラメーター
    名前 タイプ 説明
    エントリ 文字列 ジャーナルエントリの内容。
    userName 文字列 オプション。ジャーナルエントリの属性となるユーザー。
    表 : 96. 戻り値
    タイプ 説明
    なし

    次の例は、作業メモとその作成者をレコードに追加する方法を示しています。

    var now_GR = new GlideRecord("incident");
    
    now_GR.addQuery("sys_id", "<sys_id_value>");
    now_GR.query();
    
    if(now_GR.next()){
      now_GR.work_notes.setJournalEntry("Content of the journal entry.", "abel.tuter");  
      now_GR.update();
    }

    GlideElement - setValue(オブジェクト値)

    フィールドの値を設定します。

    注:
    このメソッドを呼び出す前に、既存のレコードをクエリするか、 now_GR.initialize() メソッドを使用して新しいレコードを初期化することによって、要素がすでに存在している必要があります。
    password2 フィールドを使用した認証用ではありません
    setValue() メソッドは password2 データをクリアーテキストとして渡すため、暗号化データの期待に関するエラーが発生します。さらに、password2 フィールドに setValue() メソッドを使用すると、暗号化する必要があるデータが公開されます。

    password2 認証の場合は、代わりに setDisplayValue() メソッドを使用します。

    表 : 97. パラメーター
    名前 タイプ 説明
    オブジェクト フィールドが設定される値。
    表 : 98. 戻り値
    タイプ 説明
    なし

    文字列を渡して値を設定します。

    var glideRecord = new GlideRecord('incident');
    glideRecord.query('priority','1');
    glideRecord.next();
    glideRecord.short_description.setValue('Network failure');

    オブジェクトを渡す値を設定します。

    var now_GR  = new GlideRecord('student');
    now_GR.initialize();
    now_GR.setValue('first_name', 'Joe');
    now_GR.setValue('last_name', 'Smith');
    now_GR.insert();

    スコープ対象と同等のもの

    スコープ対象のアプリケーションで setValue() メソッドを使用するには、対応するスコープ対象のメソッド setValue() を使用します。

    GlideElement:toString()

    フィールドの値を文字列に変換します。

    表 : 99. パラメーター
    名前 タイプ 説明
    なし
    表 : 100. 戻り値
    タイプ 説明
    文字列 文字列としてのフィールド値。
    doit();
     
    function doit() { 
     
      var now_GR = new GlideRecord('sys_user');
      now_GR.query();
      while (now_GR.next()) {
      if ((now_GR().length != now_GR.first_name.toString().trim().length) || (now_GR.last_name.toString().length 
             != now_GR.last_name.toString().trim().length)) {
          now_GR.first_name = now_GR.first_name.toString().trim();
          now_GR.last_name = now_GR.last_name.toString().trim();
          now_GR.autoSysFields(false);
          now_GR.update();
        }
      }
     
    }

    スコープ対象と同等のもの

    スコープ対象のアプリケーションで toString() メソッドを使用するには、対応するスコープ対象のメソッド toString() を使用します。