---
sourceDocument: Xanadu API Reference
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/xanadu/api-reference

 Release :

    - xanadu

ft:locale :

    - en-US

ft:publication_title :

    - Xanadu API Reference

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# Mobile GlideForm (g_form) - Client

# Mobile GlideForm (g_form) - Client {#ariaid-title1}

* Release version: Xanadu
* 
* Updated August 1, 2024
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 1 minute to read

The Mobile GlideForm (g_form) API provides methods to work with forms on the mobile platform.

Use these methods in any script that targets a mobile device.

## MobileGlideForm (g_form) - addDecoration(String fieldName, String icon,
String text) {#ariaid-title2}

Adds a decorative icon next to a field.
{#r_MGF-addDecoration_S_S_S__table_nbc_4dw_mt__entry__3}

| Name | Type | Description |
|-|-|-|
| fieldName | String | The field name. |
| icon | String | The font icon to show next to the field. |
| text | String | The text title for the icon (used for screen readers). |
[Table 1. Parameters]

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

| Type | Description |
|-|-|
| void |   |
[Table 2. Returns]

{#r_MGF-addDecoration_S_S_S__table_obc_4dw_mt}  
This example adds a VIP icon next to the caller.

    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(String fieldName) {#ariaid-title3}

Gets the form label text.
{#r_MGF-getLabel_S__table_jbc_4dw_mt__entry__3}

| Name | Type | Description |
|-|-|-|
| fieldName | String | The field name. |
[Table 3. Parameters]

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

| Type | Description |
|-|-|
| String | The label text. |
[Table 4. Returns]

{#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(String fieldName) {#ariaid-title4}

Determines if a field is present on the form.
Present means that it can be shown, not that it is visible.
{#r_MGF-hasField_S__table_lbc_4dw_mt__entry__3}

| Name | Type | Description |
|-|-|-|
| fieldName | String | The field to look for. |
[Table 5. Parameters]

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

| Type | Description |
|-|-|
| Boolean | True if the field is present on the form; false, if it is not. On the form means that the field is part of g_form. It could still be hidden, read-only, mandatory, or invalid. |
[Table 6. Returns]

{#r_MGF-hasField_S__table_mbc_4dw_mt}  
This example makes the assigned_to field mandatory if the assignment_group field is on the form.

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

Removes a decorative icon from next to a field.
{#r_MGF-removeDecoration_S_S_S__table_q5v_wvw_mt__entry__3}

| Name | Type | Description |
|-|-|-|
| fieldName | String | The field name. |
| icon | String | The icon to remove. |
| text | String | The text title for the icon. |
[Table 7. Parameters]

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

| Type | Description |
|-|-|
| void |   |
[Table 8. Returns]

{#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(String fieldName, String label) {#ariaid-title6}

Sets the form label text.
{#r_MGF-setLabel_S_S__table_fbc_4dw_mt__entry__3}

| Name | Type | Description |
|-|-|-|
| fieldName | String | The field name. |
| label | String | The field label text. |
[Table 9. Parameters]

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

| Type | Description |
|-|-|
| void |   |
[Table 10. Returns]

{#r_MGF-setLabel_S_S__table_gbc_4dw_mt}  
This example changes the comments label.

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


