GlideElement - グローバル

  • リリースバージョン: Zurich
  • 更新日 2025年07月31日
  • 所要時間:61分
  • 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」を返します。
    表 : 7. パラメーター
    名前 タイプ 説明
    なし
    表 : 8. 返される内容
    タイプ 説明
    ブーリアン フィールドが変更されている場合は true、されていない場合は false。

    ビジネスルールからの次の例は、[assigned_to] フィールドの値が変更された場合に EventQueue にイベントを作成する方法を示しています。

    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(オブジェクト value)

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

    注:
    このメソッドを実行している GlideRecord が初期化されて読み込まれているだけで、書き込まれていない場合、基になる前後の値は同じです。この場合、データストアに変更がないため、メソッドは「false」を返します。
    表 : 9. パラメーター
    名前 タイプ 説明
    value オブジェクト 現在のフィールドの前の値と照合するオブジェクト値。
    表 : 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(オブジェクト value)

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

    注:
    changesTo() メソッドは ACL スクリプト内ではサポートされていません。
    注:
    このメソッドを実行している GlideRecord が初期化されて読み込まれているだけで、書き込まれていない場合、基になる前後の値は同じです。この場合、データストアに変更がないため、メソッドは「false」を返します。
    表 : 11. パラメーター
    名前 タイプ 説明
    value オブジェクト 現在のフィールドの新しい値と照合するオブジェクト値。
    表 : 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 以降のミリ秒数を返します。期間フィールドはすでに 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(文字列) を使用してデバッグメッセージを追加します。

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

    GlideElement - getAttribute(文字列 attributeName)

    指定された属性の値をディクショナリから返します。

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

    表 : 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(文字列) を使用します。

    表 : 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(文字列 dependent)

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

    表 : 23. パラメーター
    名前 タイプ 説明
    dependent 文字列 オプション。選択リストフィールドが依存する関連レコード内のフィールド。
    表 : 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. 返される内容
    タイプ 説明
    文字列 選択肢ラベル。

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

    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(数値 maxChar, 文字列 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. パラメーター
    名前 タイプ 説明
    言語 文字列 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(文字列 value)

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

    表 : 41. パラメーター
    名前 タイプ 説明
    value 文字列 返す値の要素。
    表 : 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(数値 maxChars)

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

    表 : 53. パラメーター
    名前 タイプ 説明
    maxChars 数値 オプション。返される最大文字数。
    表 : 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 文字列 表示値が 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(数値 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. パラメーター
    名前 タイプ 説明
    言語 文字列 IETF BCP-47に準拠した言語タグです。
    表 : 62. 戻り値
    タイプ 説明
    文字列 渡された言語のフィールドラベルの値。 翻訳が利用できない場合、メソッドは現在のユーザーの言語に翻訳された値を取得します。翻訳が利用できない場合、結果はデフォルトで英語になります。

    次の例は、元のラベル テキストと、 Accept (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
    

    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(数値 milliseconds)

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

    表 : 87. パラメーター
    名前 タイプ 説明
    milliseconds 数値 期間がまたがるミリ秒数。
    表 : 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(文字列 message)

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

    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(オブジェクト value)

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

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

    表 : 93. パラメーター
    名前 タイプ 説明
    value オブジェクト フィールドの初期値。
    表 : 94. 返される内容
    タイプ 説明
    なし

    GlideElement - setJournalEntry(文字列 entry, 文字列 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(オブジェクト value)

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

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

    password2 認証の場合は、代わりに setDisplayValue() メソッドを使用してください。

    表 : 97. パラメーター
    名前 タイプ 説明
    value オブジェクト フィールドに設定される値。
    表 : 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() を使用します。