---
sourceDocument: Xanadu API リファレンス
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/ja-JP/xanadu/api-reference

 Release :

    - xanadu

ft:locale :

    - ja-JP

ft:publication_title :

    - Xanadu API リファレンス

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

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

# Mobile GlideForm (g_form) - クライアント {#ariaid-title1}

* リリースバージョン: Xanadu
* 
* 更新日 2024年08月01日
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 所要時間：4分

モバイル GlideForm (g_form) API は、モバイルプラットフォーム上でフォームを操作するためのメソッドを提供します。

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

## MobileGlideForm (g_form) - addDecoration(文字列 fieldName, 文字列 icon, 文字列 text) {#ariaid-title2}

フィールドの横に装飾アイコンを追加します。
{#r_MGF-addDecoration_S_S_S__table_nbc_4dw_mt__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| fieldName | 文字列 | フィールド名 |
| アイコン | 文字列 | フィールドの横に表示するフォントアイコン。 |
| テキスト | 文字列 | アイコンのテキストタイトル (スクリーンリーダーに使用)。 |
[表 : 1. パラメーター]

{#r_MGF-addDecoration_S_S_S__table_nbc_4dw_mt} {#r_MGF-addDecoration_S_S_S__table_obc_4dw_mt__entry__2}

| タイプ | 説明 |
|-|-|
| なし |   |
[表 : 2. 返される内容]

{#r_MGF-addDecoration_S_S_S__table_obc_4dw_mt}  
この例では、問い合わせユーザーの横に 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) {#ariaid-title3}

フォームラベルテキストを取得します。
{#r_MGF-getLabel_S__table_jbc_4dw_mt__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| fieldName | 文字列 | フィールド名 |
[表 : 3. パラメーター]

{#r_MGF-getLabel_S__table_jbc_4dw_mt} {#r_MGF-getLabel_S__table_kbc_4dw_mt__entry__2}

| タイプ | 説明 |
|-|-|
| 文字列 | ラベルテキスト。 |
[表 : 4. 返される内容]

{#r_MGF-getLabel_S__table_kbc_4dw_mt}  

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

## MobileGlideForm (g_form) - hasField(文字列 fieldName) {#ariaid-title4}

フォームにフィールドが存在するかどうかを判断します。
「存在する」とは表示できることを意味し、表示されるという意味ではありません。
{#r_MGF-hasField_S__table_lbc_4dw_mt__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| fieldName | 文字列 | 検索するフィールド。 |
[表 : 5. パラメーター]

{#r_MGF-hasField_S__table_lbc_4dw_mt} {#r_MGF-hasField_S__table_mbc_4dw_mt__entry__2}

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

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

    if (g_form.hasField('assignment_group'))
          g_form.setMandatory('assigned_to', true);
        
## MobileGlideForm (g_form) - removeDecoration(文字列 fieldName, 文字列 icon, 文字列 text) {#ariaid-title5}

フィールドの横から装飾アイコンを削除します。
{#r_MGF-removeDecoration_S_S_S__table_q5v_wvw_mt__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| fieldName | 文字列 | フィールド名 |
| アイコン | 文字列 | 削除するアイコン。 |
| テキスト | 文字列 | アイコンのテキストタイトル。 |
[表 : 7. パラメーター]

{#r_MGF-removeDecoration_S_S_S__table_q5v_wvw_mt} {#r_MGF-removeDecoration_S_S_S__table_t5v_wvw_mt__entry__2}

| タイプ | 説明 |
|-|-|
| なし |   |
[表 : 8. 返される内容]

{#r_MGF-removeDecoration_S_S_S__table_t5v_wvw_mt}  

    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) {#ariaid-title6}

フォームラベルテキストを設定します。
{#r_MGF-setLabel_S_S__table_fbc_4dw_mt__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| fieldName | 文字列 | フィールド名 |
| label | 文字列 | フィールドラベルテキスト。 |
[表 : 9. パラメーター]

{#r_MGF-setLabel_S_S__table_fbc_4dw_mt} {#r_MGF-setLabel_S_S__table_gbc_4dw_mt__entry__2}

| タイプ | 説明 |
|-|-|
| なし |   |
[表 : 10. 返される内容]

{#r_MGF-setLabel_S_S__table_gbc_4dw_mt}  
この例ではコメントラベルを変更します。

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


