Mobile GlideForm (g_form) - クライアント

  • リリースバージョン: Zurich
  • 更新日 2025年07月31日
  • 所要時間:4分
  • Mobile GlideForm (g_form) API は、モバイルプラットフォームでフォームを操作するためのメソッドを提供します。

    これらのメソッドは、モバイルデバイスをターゲットとするスクリプトで使用します。

    MobileGlideForm (g_form) - addDecoration(文字列 fieldName, 文字列 icon, 文字列 text)

    フィールドの横に装飾アイコンを追加します。

    表 : 1. パラメーター
    名前 タイプ 説明
    fieldName 文字列 フィールド名
    アイコン 文字列 フィールドの横に表示するフォントアイコン。
    テキスト 文字列 アイコンのテキストタイトル (スクリーンリーダーに使用)。
    表 : 2. 返される内容
    タイプ 説明
    なし

    この例では、問い合わせユーザーの横に VIP アイコンを追加します。

    function onChange(control, oldValue, newValue, isLoading) {
          // if the caller_id field is not present, then we can't add an icon anywhere
          if (!g_form.hasField('caller_id'))
              return;
          
          if (!newValue)
             return;
          
          g_form.getReference('caller_id', function(ref) {
          g_form.removeDecoration('caller_id', 'icon-star', 'VIP');
          
          if (ref.getValue('vip') == 'true')
               g_form.addDecoration('caller_id', 'icon-star', 'VIP');			
          });
          }

    MobileGlideForm (g_form) - getLabel(文字列 fieldName)

    フォームラベルテキストを取得します。

    表 : 3. パラメーター
    名前 タイプ 説明
    fieldName 文字列 フィールド名
    表 : 4. 返される内容
    タイプ 説明
    文字列 ラベルテキスト。
    if (g_user.hasRole('itil')) {
          var oldLabel = g_form.getLabel('comments');
          g_form.setLabel('comments', oldLabel + ' (Customer visible)');
          }

    MobileGlideForm (g_form) - hasField(文字列 fieldName)

    フォームにフィールドが存在するかどうかを判断します。

    「存在する」とは表示できることを意味し、表示されるという意味ではありません。

    表 : 5. パラメーター
    名前 タイプ 説明
    fieldName 文字列 検索するフィールド。
    表 : 6. 返される内容
    タイプ 説明
    ブーリアン フィールドがフォーム上に存在する場合は true、そうでない場合は false。「フォーム上」とはフィールドが g_form の一部であることを意味します。ただし、非表示、読み取り専用、必須、または無効である可能性があります。

    この例では、[assignment_group] フィールドがフォーム上にある場合、[assigned_to] フィールドが必須になります。

    if (g_form.hasField('assignment_group'))
          g_form.setMandatory('assigned_to', true);
        

    MobileGlideForm (g_form) - removeDecoration(文字列 fieldName, 文字列 icon, 文字列 text)

    フィールドの横から装飾アイコンを削除します。

    表 : 7. パラメーター
    名前 タイプ 説明
    fieldName 文字列 フィールド名
    アイコン 文字列 削除するアイコン。
    テキスト 文字列 アイコンのテキストタイトル。
    表 : 8. 返される内容
    タイプ 説明
    なし
    function onChange(control, oldValue, newValue, isLoading) {
          // if the caller_id field is not present, then we can't add an icon anywhere
          if (!g_form.hasField('caller_id'))
               return;
          
          if (!newValue)
               return;
          
          g_form.getReference('caller_id', function(ref) {
               g_form.removeDecoration('caller_id', 'icon-star', 'VIP');
          
               if (ref.getValue('vip') == 'true')
                    g_form.addDecoration('caller_id', 'icon-star', 'VIP');			
          });
          }

    MobileGlideForm (g_form) - setLabel(文字列 fieldName, 文字列 label)

    フォームラベルテキストを設定します。

    表 : 9. パラメーター
    名前 タイプ 説明
    fieldName 文字列 フィールド名
    label 文字列 フィールドラベルテキスト。
    表 : 10. 返される内容
    タイプ 説明
    なし

    この例ではコメントラベルを変更します。

    if (g_user.hasRole('itil')) {
          var oldLabel = g_form.getLabel('comments');
          g_form.setLabel('comments', oldLabel + ' (Customer visible)');
          }