---
sourceDocument: Australia API Reference
sourceDocumentLink: https://www.servicenow.com/docs/r/api-reference

 Release :

    - australia

ft:locale :

    - en-US

ft:publication_title :

    - Australia API Reference

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# GlideForm (g_form) - Client

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

* Release version: Australia
* 
* Updated March 12, 2026
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 43 minutes to read

The GlideForm API provides methods to customize forms.

Only use GlideForm methods on the client. You can use these methods to make custom changes to the form view of records. All validation of examples was done using client scripts.

You can also use some of these methods in other client scripts (such as Catalog Client Scripts or Wizard Client Scripts), but you must first test this to determine whether they will work as expected.  
Note:  
The methods getControl(), getHelpTextControl(), getElement(), and getFormElement() are deprecated for mobile devices. For information on using GlideForm for mobile, see [Mobile Client GlideForm (g_form) Scripting and Migration](https://www.servicenow.com/docs/KKqK2Nyj31SSGzVtyS74nw "Client scripting for mobile is identical to scripting for the web, with some exceptions. All new scripts must conform to certain guidelines. The following items are affected on the mobile platform: client scripts, UI policies, navigator modules, and UI actions.").

There is no constructor for the GlideForm class. Access GlideForm methods using the `g_form` global object.

## GlideForm - addDecoration(String fieldName, String icon, String title) {#ariaid-title2}

Adds an icon on a field's label.
Adding the same item twice is prevented; however, you can add the same icon with a different title.  
Note:  
This method is not supported by Service Catalog.
{#r_GlideForm-AddDecoration_S_S_S__table_vyw_1dw_ts__entry__3}{#r_GlideForm-AddDecoration_S_S_S__g_form-add_decor-fieldName-entry}{#r_GlideForm-AddDecoration_S_S_S__g_form-add_decor-icon-entry}{#r_GlideForm-AddDecoration_S_S_S__g_form-add_decor-title-entry}

| Name | Type | Description |
|-|-|-|
| fieldName | String | Field name. |
| icon | String | Name of the icon to show next to the specified field. Valid values: * icon-add * icon-alert * icon-book * icon-book-open * icon-calendar * icon-cards * icon-cart-full * icon-catalog * icon-check-circle * icon-cog * icon-comment * icon-console * icon-dashboard * icon-database * icon-delete * icon-drawer * icon-edit * icon-filter * icon-folder * icon-form * icon-help * icon-home * icon-image * icon-info * icon-label * icon-lightbulb * icon-list * icon-livefeed * icon-locked * icon-mail * icon-mobile * icon-new-ticket * icon-paperclip * icon-power * icon-script * icon-search * icon-sort-ascending * icon-star * icon-star-empty * icon-tab * icon-trash * icon-tree * icon-tree-right * icon-user * icon-user-group * icon-view {#r_GlideForm-AddDecoration_S_S_S__ul_p2d_sqg_5fc} |
| title | String | Title for the icon. |
[Table 1. Parameters]

{#r_GlideForm-AddDecoration_S_S_S__table_vyw_1dw_ts} {#r_GlideForm-AddDecoration_S_S_S__table_wyw_1dw_ts__entry__2}

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

{#r_GlideForm-AddDecoration_S_S_S__table_wyw_1dw_ts}  

    g_form.addDecoration('caller_id', 'icon-star', 'preferred member');

## GlideForm - addDecoration(String fieldName, String icon, String title, String
color) {#ariaid-title3}

Adds an icon on a field's label.
Adding the same item twice is prevented; however, you can add the same icon with a different title.  
Note:  
This method is not supported by Service Catalog.
{#r_GlideForm-AddDecoration_S_S_S_S__table_gzh_fyd_5s__entry__3}{#r_GlideForm-AddDecoration_S_S_S_S__g_form-add_decor-fieldName-entry}{#r_GlideForm-AddDecoration_S_S_S_S__g_form-add_decor-icon-entry}{#r_GlideForm-AddDecoration_S_S_S_S__g_form-add_decor-title-entry}{#r_GlideForm-AddDecoration_S_S_S_S__g_form-add_decor-color-entry}

| Name | Type | Description |
|-|-|-|
| fieldName | String | Field name. |
| icon | String | Name of the icon to show next to the specified field. Valid values: * icon-add * icon-alert * icon-book * icon-book-open * icon-calendar * icon-cards * icon-cart-full * icon-catalog * icon-check-circle * icon-cog * icon-comment * icon-console * icon-dashboard * icon-database * icon-delete * icon-drawer * icon-edit * icon-filter * icon-folder * icon-form * icon-help * icon-home * icon-image * icon-info * icon-label * icon-lightbulb * icon-list * icon-livefeed * icon-locked * icon-mail * icon-mobile * icon-new-ticket * icon-paperclip * icon-power * icon-script * icon-search * icon-sort-ascending * icon-star * icon-star-empty * icon-tab * icon-trash * icon-tree * icon-tree-right * icon-user * icon-user-group * icon-view {#r_GlideForm-AddDecoration_S_S_S_S__ul_p2d_sqg_5fc} |
| title | String | Title for the icon. |
| color | String | CSS color. |
[Table 3. Parameters]

{#r_GlideForm-AddDecoration_S_S_S_S__table_gzh_fyd_5s} {#r_GlideForm-AddDecoration_S_S_S_S__table_hzh_fyd_5s__entry__2}

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

{#r_GlideForm-AddDecoration_S_S_S_S__table_hzh_fyd_5s}  

    g_form.addDecoration('caller_id', 'icon-star', 'Mark as Favorite', 'color-green');

## GlideForm - addErrorMessage(String message) {#ariaid-title4}

Displays the specified error message at the top of the form.
This message appears for approximately four seconds and then disappears. This timeout is
not configurable at this time.
{#r_GlideFormAddErrorMessage_String__table_fyn_vnd_5s__entry__3}{#r_GlideFormAddErrorMessage_String__g_form-add_err_msg-message-entry}

| Name | Type | Description |
|-|-|-|
| message | String | Message to display. |
[Table 5. Parameters]

{#r_GlideFormAddErrorMessage_String__table_fyn_vnd_5s} {#r_GlideFormAddErrorMessage_String__table_gyn_vnd_5s__entry__2}

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

{#r_GlideFormAddErrorMessage_String__table_gyn_vnd_5s}  

    g_form.addErrorMessage('This is an error');

## GlideForm - addFormMessage(String message, String type, Object options) {#ariaid-title5}

Displays a floating form message at the top of the form detail section. The message doesn't cover UI actions.
See also:

* [clearAllFormMessages()](https://www.servicenow.com/docs/HNdDSrkfvw56bJr9GUeUlA#GF-clearAllFormMessages "Removes all form messages of any type.")
* [clearFormMessages()](https://www.servicenow.com/docs/HNdDSrkfvw56bJr9GUeUlA#GF-clearFormMessages_S "Removes all form messages of a specified type.")
{#GF-addFormMessage_S_S__ul_unz_vkt_4pb}
{#GF-addFormMessage_S_S__table_f2v_zym_4pb__entry__3}{#GF-addFormMessage_S_S__g_form-add_form_msg-message-entry}{#GF-addFormMessage_S_S__glideform-parm-type-entry}{#GF-addFormMessage_S_S__g_form-add_form_msg-options-entry}{#GF-addFormMessage_S_S__g_form-add_form_msg-options_buttons-entry}{#GF-addFormMessage_S_S__g_form-add_form_msg-options_buttons_actionName-entry}{#GF-addFormMessage_S_S__g_form-add_form_msg-options_buttons_label-entry}{#GF-addFormMessage_S_S__g_form-add_form_msg-options_meta-entry}

| Name | Type | Description |
|-|-|-|
| message | String | Message to display. |
| type | String | Type of message. Valid values: * error * info * warning {#GF-addFormMessage_S_S__ul_mgd_sqg_5fc} |
| options | Object | Optional. Buttons to add to the form message and any metadata needed to handle a button click. { buttons: [Array], meta: {Object} } |
| options.buttons | Array | List of buttons to add to the form message. buttons: [ { actionName: "String", label: "String" } ] |
| options.buttons.actionName | String | Name used by the `FORM_MESSAGE_BUTTON_CLICKED` event handlers to determine the button that was clicked. For example, if you add a button with the actionName `assign_to_me`, you must create an event handler in UIB on the `FORM_MESSAGE_BUTTON_CLICKED` event that only executes when the actionName is `assigned_to_me`. |
| options.buttons.label | String | Text to display on the button. |
| options.meta | Object | Map of any metadata needed to handle the button click formatted as key-value pairs. meta: { 'key': 'value' } For example, for an Assign to me button the event handler needs the sys_id of the user to assign the record to. |
[Table 7. Parameters]

{#GF-addFormMessage_S_S__table_f2v_zym_4pb} {#GF-addFormMessage_S_S__table_g2v_zym_4pb__entry__2}

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

{#GF-addFormMessage_S_S__table_g2v_zym_4pb}  
The following example shows how to add form messages of each type.

    g_form.addFormMessage('info message','info');
    g_form.addFormMessage('warning message','warning');
    g_form.addFormMessage('error message','error');
    g_form.addFormMessage('info2 message','info');
    g_form.addFormMessage('warning2 message','warning');
    g_form.addFormMessage('error2 message','error');
    g_form.addFormMessage('Would you like to reassign this to yourself?', 'info', {buttons: [{label: "Assign to me", actionName: "assign_to_me"}], meta: {'userId': '46d44a23a9fe19810012d100cca80666'}});

## GlideForm - addHighMessage(String message) {#ariaid-title6}

Displays a high priority message at the top of the form.
This message appears for approximately four seconds and then disappears. This timeout is not configurable at this time.
{#GF-addHighMessage_S__table_ft2_hk4_2fc__entry__3}

| Name | Type | Description |
|-|-|-|
| message | String | High priority message to display on the form. |
[Table 9. Parameters]

{#GF-addHighMessage_S__table_ft2_hk4_2fc} {#GF-addHighMessage_S__table_gt2_hk4_2fc__entry__2}

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

{#GF-addHighMessage_S__table_gt2_hk4_2fc}  
The following example shows how to display a high priority message at the top of the form.

    g_form.addHighMessage("This is a high priority message");

## GlideForm - addInfoMessage(String message) {#ariaid-title7}

Adds the specified informational message to the top of the form.
This message appears for approximately four seconds and then disappears. This timeout is not configurable at this time.
{#r_GlideFormAddInfoMessage_String__table_pcg_n4d_5s__entry__3}{#r_GlideFormAddInfoMessage_String__g_form-add_info_msg-message-entry}

| Name | Type | Description |
|-|-|-|
| message | String | Message to display. |
[Table 11. Parameters]

{#r_GlideFormAddInfoMessage_String__table_pcg_n4d_5s} {#r_GlideFormAddInfoMessage_String__table_qcg_n4d_5s__entry__2}

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

{#r_GlideFormAddInfoMessage_String__table_qcg_n4d_5s}  

    g_form.addInfoMessage('The top five fields in this form are mandatory');

## GlideForm - addLowMessage(String message) {#ariaid-title8}

Displays a low priority message at the top of the form.
This message appears for approximately four seconds and then disappears. This timeout is not configurable at this time.
{#GF-addLowMessage_S__table_ydn_fj4_2fc__entry__3}

| Name | Type | Description |
|-|-|-|
| message | String | Low priority message to display on the form. |
[Table 13. Parameters]

{#GF-addLowMessage_S__table_ydn_fj4_2fc} {#GF-addLowMessage_S__table_zdn_fj4_2fc__entry__2}

| Type | Description |
|-|-|
| None |   |
[Table 14. Returns]

{#GF-addLowMessage_S__table_zdn_fj4_2fc}  
The following example shows how to display a low priority message at the top of the form.

    g_form.addLowMessage("This is a low priority message"); 

## GlideForm - addModerateMessage(String message) {#ariaid-title9}

Displays a moderate level priority message at the top of the form.
This message appears for approximately four seconds and then disappears. This timeout is not configurable at this time.
{#GF-addModerateMessage_S__table_kfb_vj4_2fc__entry__3}

| Name | Type | Description |
|-|-|-|
| message | String | Moderate priority message to display on the form. |
[Table 15. Parameters]

{#GF-addModerateMessage_S__table_kfb_vj4_2fc} {#GF-addModerateMessage_S__table_lfb_vj4_2fc__entry__2}

| Type | Description |
|-|-|
| None |   |
[Table 16. Returns]

{#GF-addModerateMessage_S__table_lfb_vj4_2fc}  
The following example shows how to display a moderate priority message at the top of the form.

    g_form.addModerateMessage("This is a moderate priority message");

## GlideForm - addOption(String fieldName, String choiceValue, String choiceLabel) {#ariaid-title10}

Adds a choice to the end of a specified choice list field.
{#r_GF-AddOption_S_S_S__table_omk_pgd_5s__entry__3}{#r_GF-AddOption_S_S_S__g_form-addOption-fieldName-entry}{#r_GF-AddOption_S_S_S__g_form-addOption-choiceValue-entry}{#r_GF-AddOption_S_S_S__g_form-addOption-choiceLabel-entry}

| Name | Type | Description |
|-|-|-|
| fieldName | String | Name of the field in which to add the choice field option. |
| choiceValue | String | Value to store in the database. |
| choiceLabel | String | Value to display. |
[Table 17. Parameters]

{#r_GF-AddOption_S_S_S__table_omk_pgd_5s} {#r_GF-AddOption_S_S_S__table_pmk_pgd_5s__entry__2}

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

{#r_GF-AddOption_S_S_S__table_pmk_pgd_5s}  

    g_form.addOption('priority', '6', '6 - Really Low');

## GlideForm - addOption(String fieldName, String choiceValue, String choiceLabel, Number
choiceIndex) {#ariaid-title11}

Adds a choice to the list field at the position specified.
Note:  
Duplicate list labels are not supported in Service Portal. For example, items with label text matching another label are ignored and not added to the list.
{#r_GlideForm-AddOption_S_S_S_N__table_k5s_qhd_5s__entry__3}{#r_GlideForm-AddOption_S_S_S_N__g_form-addOption-fieldName-entry}{#r_GlideForm-AddOption_S_S_S_N__g_form-addOption-choiceValue-entry}{#r_GlideForm-AddOption_S_S_S_N__g_form-addOption-choiceLabel-entry}{#r_GlideForm-AddOption_S_S_S_N__g_form-addOption-choiceIndex-entry}

| Name | Type | Description |
|-|-|-|
| fieldName | String | Name of the field in which to add the choice field option. |
| choiceValue | String | Value to store in the database. |
| choiceLabel | String | Value to display. |
| choiceIndex | Number | Order of the choice in the list. The index is a zero-based array. |
[Table 19. Parameters]

{#r_GlideForm-AddOption_S_S_S_N__table_k5s_qhd_5s} {#r_GlideForm-AddOption_S_S_S_N__table_l5s_qhd_5s__entry__2}

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

{#r_GlideForm-AddOption_S_S_S_N__table_l5s_qhd_5s}  

    g_form.addOption('priority', '2.5', '2.5 - Moderately High', 3);

## GlideForm - addSuccessMessage(String message) {#ariaid-title12}

Displays a success message at the top of the form.
This message appears for approximately four seconds and then disappears. This timeout is not configurable at this time.
{#GF-addSuccessMessage_S__table_mln_jh4_2fc__entry__3}

| Name | Type | Description |
|-|-|-|
| message | String | Success message to display on the form. |
[Table 21. Parameters]

{#GF-addSuccessMessage_S__table_mln_jh4_2fc} {#GF-addSuccessMessage_S__table_nln_jh4_2fc__entry__2}

| Type | Description |
|-|-|
| None |   |
[Table 22. Returns]

{#GF-addSuccessMessage_S__table_nln_jh4_2fc}  
The following example shows how to display a message confirming a success message at the top of the form.

    g_form.addSuccessMessage("This is a success message");

## GlideForm - clearAllFormMessages() {#ariaid-title13}

Removes all form messages of any type.
See also:

* [addFormMessage()](https://www.servicenow.com/docs/HNdDSrkfvw56bJr9GUeUlA#GF-addFormMessage_S_S "Displays a floating form message at the top of the form detail section. The message doesn't cover UI actions.")
* [clearFormMessages()](https://www.servicenow.com/docs/HNdDSrkfvw56bJr9GUeUlA#GF-clearFormMessages_S "Removes all form messages of a specified type.")
{#GF-clearAllFormMessages__ul_unz_vkt_4pb}
{#GF-clearAllFormMessages__table_qpm_dzm_4pb__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 23. Parameters]

{#GF-clearAllFormMessages__table_qpm_dzm_4pb} {#GF-clearAllFormMessages__table_rpm_dzm_4pb__entry__2}

| Type | Description |
|-|-|
| None |   |
[Table 24. Returns]

{#GF-clearAllFormMessages__table_rpm_dzm_4pb}  
The following example shows how to clear all messages from the form.

    g_form.clearAllFormMessages();

## GlideForm - clearFormMessages(String type) {#ariaid-title14}

Removes all form messages of a specified type.
See also:

* [addFormMessage()](https://www.servicenow.com/docs/HNdDSrkfvw56bJr9GUeUlA#GF-addFormMessage_S_S "Displays a floating form message at the top of the form detail section. The message doesn't cover UI actions.")
* [clearAllFormMessages()](https://www.servicenow.com/docs/HNdDSrkfvw56bJr9GUeUlA#GF-clearAllFormMessages "Removes all form messages of any type.")
{#GF-clearFormMessages_S__ul_unz_vkt_4pb}
{#GF-clearFormMessages_S__table_ilw_bzm_4pb__entry__3}{#GF-clearFormMessages_S__glideform-parm-type-entry}

| Name | Type | Description |
|-|-|-|
| type | String | Type of message. Valid values: * error * info * warning {#GF-clearFormMessages_S__ul_mgd_sqg_5fc} |
[Table 25. Parameters]

{#GF-clearFormMessages_S__table_ilw_bzm_4pb} {#GF-clearFormMessages_S__table_jlw_bzm_4pb__entry__2}

| Type | Description |
|-|-|
| None |   |
[Table 26. Returns]

{#GF-clearFormMessages_S__table_jlw_bzm_4pb}  
The following example shows how to clear all error messages from the form.

    g_form.clearFormMessages('error');

## GlideForm - clearMessages() {#ariaid-title15}

Removes all informational and error messages from the top of the form.
Removes informational and error messages added with
g_form.addInfoMessage() and
g_form.addErrorMessage().
{#r_GlideFormClearMessages__table_krr_y4d_5s__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 27. Parameters]

{#r_GlideFormClearMessages__table_krr_y4d_5s} {#r_GlideFormClearMessages__table_lrr_y4d_5s__entry__2}

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

{#r_GlideFormClearMessages__table_lrr_y4d_5s}  

    g_form.clearMessages();

## GlideForm - clearOptions(String fieldName) {#ariaid-title16}

Removes all options from the specified choice list.
{#r_GlideFormClearOptions_String__table_bdt_v3d_5s__entry__3}{#r_GlideFormClearOptions_String__g_form-clearOptions-fieldName-entry}

| Name | Type | Description |
|-|-|-|
| fieldName | String | Name of the field for which to clear the choice options. |
[Table 29. Parameters]

{#r_GlideFormClearOptions_String__table_bdt_v3d_5s} {#r_GlideFormClearOptions_String__table_cdt_v3d_5s__entry__2}

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

{#r_GlideFormClearOptions_String__table_cdt_v3d_5s}

## GlideForm - clearValue(String fieldName) {#ariaid-title17}

Removes any value(s) from the specified field.
Note:  
This method can't be used to update fields set to strict read only. If this method is called on strict read only fields, the field isn't updated and a warning is logged in the browser console. For more information, see [Configuring read-only security options](https://www.servicenow.com/docs/access?context=read-only-option&version=australia&pubname=australia-platform-administration&ft:locale=en-US).
{#r_GlideFormClearValue_String__table_tlr_znc_5s__entry__3}{#r_GlideFormClearValue_String__g_form-clearValue-fieldName-entry}

| Name | Type | Description |
|-|-|-|
| fieldName | String | Name of the field to clear. |
[Table 31. Parameters]

{#r_GlideFormClearValue_String__table_tlr_znc_5s} {#r_GlideFormClearValue_String__table_ulr_znc_5s__entry__2}

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

{#r_GlideFormClearValue_String__table_ulr_znc_5s}

## GlideForm - disableAttachments() {#ariaid-title18}

Prevents file attachments from being added to the form.
This method is not available on the mobile platform. If this method is run on a mobile
platform, no action occurs.
{#r_GlideFormDisableAttachments__table_ggk_bqd_5s__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 33. Parameters]

{#r_GlideFormDisableAttachments__table_ggk_bqd_5s} {#r_GlideFormDisableAttachments__table_hgk_bqd_5s__entry__2}

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

{#r_GlideFormDisableAttachments__table_hgk_bqd_5s}

## GlideForm - disableChoice(String fieldName, String choiceValue) {#ariaid-title19}

Programmatically disables a specific choice in the drop-down field, if the choice exists. No changes are made if the choice is already disabled.
{#GF-disableChoice_S_S__table_q2s_gds_rfc__entry__3}

| Name | Type | Description |
|-|-|-|
| fieldName | String | Field name of the choice to disable. Data type: String |
| choiceValue | String | Value of the choice to disable. Data type: String |
[Table 35. Parameters]

{#GF-disableChoice_S_S__table_q2s_gds_rfc} {#GF-disableChoice_S_S__table_fvm_xbs_rfc__entry__2}

| Type | Description |
|-|-|
| Boolean | Flag that indicates whether the given choice is disabled or active in the form. Valid values: * true: Choice is disabled. * false: Option is already disabled or is not found. Data type: Boolean |
[Table 36. Returns]

{#GF-disableChoice_S_S__table_fvm_xbs_rfc}  
The following example calls disableChoice() to disables the loading_dock choice in the delivery_location form field.

    if (g_form.getValue('address_type') == 'home') {
    	g_form.disableChoice('delivery_location', 'loading_dock');
    }

    // Only itil_admin users can select the "Closed" option  

    function onLoad() {
    	if (g_user.hasRole('itil_admin')) return;

    	if (g_form.getValue('incident_state') != '7')
    		g_form.disableChoice('incident_state', 7);

    	if (g_form.getValue('state') != '7') {
    		g_form.disableChoice('state', 7);
    	}

    }

## GlideForm - enableAttachments() {#ariaid-title20}

Allows file attachments to be added to the form. Shows the paper clip icon.
This method is not available on the mobile platform. If this method is run on a mobile
platform, no action occurs.
{#r_GlideFormEnableAttachments__table_i3c_ppd_5s__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 37. Parameters]

{#r_GlideFormEnableAttachments__table_i3c_ppd_5s} {#r_GlideFormEnableAttachments__table_j3c_ppd_5s__entry__2}

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

{#r_GlideFormEnableAttachments__table_j3c_ppd_5s}

## GlideForm - enableChoice(String fieldName, String choiceValue) {#ariaid-title21}

Programmatically enables a specific choice in the drop-down field, if the choice exists. No changes are made if the option is already enabled.
{#GF-enableChoice_S_S__table_q2s_gds_rfc__entry__3}

| Name | Type | Description |
|-|-|-|
| fieldName | String | Field name of the choice to enable. |
| choiceValue | String | Value of the choice to enable. |
[Table 39. Parameters]

{#GF-enableChoice_S_S__table_q2s_gds_rfc} {#GF-enableChoice_S_S__table_fvm_xbs_rfc__entry__2}

| Type | Description |
|-|-|
| Boolean | Flag that indicates whether the given choice is successfully enabled. Valid values: * true: Choice is enabled. * false: Choice is already enabled or is not found. {#GF-enableChoice_S_S__ul_sxx_tcs_rfc} Data type: Boolean |
[Table 40. Returns]

{#GF-enableChoice_S_S__table_fvm_xbs_rfc}  
The following example calls enable() to enable a new drop-down choice, `1`, in the `priority` form field.

    var shortDescription = g_form.getValue('shortDescription');

    // Allow priority 1 selection if short description mentions security 
    if (shortDescription.includes('security')) {
    	var p1Choice = g_form.getChoice('priority', '1');
    	g_form.enableChoice('priority', '1');
    }

## GlideForm - flash(String fieldName, String color, Number count) {#ariaid-title22}

Use to draw attention to a field. Flashes the specified color for a specified duration of time in the specified field.
This method is not supported by Service Catalog.

This method is not available on the mobile platform. If this method is run on a mobile
platform, no action occurs.
{#r_GlideFormFlash_String_String_Number__table_htn_w2w_ts__entry__3}{#r_GlideFormFlash_String_String_Number__g_form-flash-fieldName-entry}{#r_GlideFormFlash_String_String_Number__g_form-flash-color-entry}{#r_GlideFormFlash_String_String_Number__g_form-flash-count-entry}

| Name | Type | Description |
|-|-|-|
| fieldName | String | Field to highlight in the following format: `"<table-name>.<field-name>"`. |
| color | String | RGB color or acceptable CSS color. |
| count | Number | How long the label will flash. Valid values: * 2: Flashes for 1 second * 0: Flashes for 2 seconds * -2: Flashes for 3 seconds * -4: Flashes for 4 seconds {#r_GlideFormFlash_String_String_Number__ul_idd_sqg_5fc} |
[Table 41. Parameters]

{#r_GlideFormFlash_String_String_Number__table_htn_w2w_ts} {#r_GlideFormFlash_String_String_Number__table_itn_w2w_ts__entry__2}

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

{#r_GlideFormFlash_String_String_Number__table_itn_w2w_ts}  

    g_form.flash("incident.number", "#FFFACD", 0);

## GlideForm - getActionName() {#ariaid-title23}

Returns the most recent action name, or, for a client script, the sys_id of the UI action clicked.
Note:  
Not available in Wizard client scripts.
{#r_GlideFormGetActionName__table_zhn_xjd_5s__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 43. Parameters]

{#r_GlideFormGetActionName__table_zhn_xjd_5s} {#r_GlideFormGetActionName__table_a3n_xjd_5s__entry__2}

| Type | Description |
|-|-|
| String | Current action name or sys_id of the UI action clicked. |
[Table 44. Returns]

{#r_GlideFormGetActionName__table_a3n_xjd_5s}  

    function onSubmit() {
       var action = g_form.getActionName();
       alert('You pressed ' + action);
    }

## GlideForm - getAnnotationByName(String name) {#ariaid-title24}

Returns a form annotation of a given name.
[Annotations](https://www.servicenow.com/docs/access?context=configure-form-layout&version=australia&pubname=australia-platform-administration&section=t_AddAFormAnnotation&ft:locale=en-US) are visual separators between form elements, or blocks of colored text used to highlight form elements. Use [GlideForm - getAnnotationByName(String name)](https://www.servicenow.com/docs/HNdDSrkfvw56bJr9GUeUlA#GF-getAnnotationByName_S "Returns a form annotation of a given name.") to return all annotations in a form.
{#GF-getAnnotationByName_S__table_skr_c4l_rfc__entry__3}

| Name | Type | Description |
|-|-|-|
| name | String | The name of the annotation to return. Table: Form Annotations \[sys_ui_annotation\], Field: Name |
[Table 45. Parameters]

{#GF-getAnnotationByName_S__table_skr_c4l_rfc} {#GF-getAnnotationByName_S__table_irm_qnl_rfc__entry__2}

| Property | Description |
|-|-|
| Array of Objects | Content of the annotation. Data type: Array of Objects [{content: "String", name: "String", visible: Boolean}] |
| array.content | Text of the returned annotation. Data type: String |
| array.name | Name of the returned annotation. Data type: String Table location: Form Annotations \[sys_ui_annotation\], Field: name |
| array.visible | Flag that indicates whether the annotation is visible on the form. Valid values: * true: The annotation is visible. * false: The annotation isn't visible. {#GF-getAnnotationByName_S__ul_z2j_4tl_rfc} Data type: Boolean |
[Table 46. Returns]

{#GF-getAnnotationByName_S__table_irm_qnl_rfc}  
The following example demonstrates how to use the getAnnotationByName() method to retrieve a form annotation according to its given name, test-annotation-msg-1.

       var sampleAnnotation = g_form.getAnnotationByName("test-annotation-msg-1");

       /* returns:  
       { 
           "name": "test-annotation-msg-1", 
           "visible": true, 
           "content": "Test<input id=\"make_spacing_ok\" style=\"visibility:hidden; width:0px;\">" 
       }
       */

## GlideForm - getAnnotations() {#ariaid-title25}

Returns a list of all annotations on a form.
[Annotations](https://www.servicenow.com/docs/access?context=configure-form-layout&version=australia&pubname=australia-platform-administration&section=t_AddAFormAnnotation&ft:locale=en-US) are visual separators between form elements, or blocks of colored text used to highlight form elements. Use [GlideForm - getAnnotationByName(String name)](https://www.servicenow.com/docs/HNdDSrkfvw56bJr9GUeUlA#GF-getAnnotationByName_S "Returns a form annotation of a given name.") to return a specific annotation by its name.
{#GF-getAnnotations__table_hrm_qnl_rfc__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 47. Parameters]

{#GF-getAnnotations__table_hrm_qnl_rfc} {#GF-getAnnotations__table_irm_qnl_rfc__entry__2}

| Property | Description |
|-|-|
| Array of Objects | Content of the annotation. Data type: Array of Objects [{content: "String", name: "String", visible: Boolean}] |
| array.content | Text of the returned annotation. Data type: String |
| array.name | Name of the returned annotation. Data type: String Table location: Form Annotations \[sys_ui_annotation\], Field: name |
| array.visible | Flag that indicates whether the annotation is visible on the form. Valid values: * true: The annotation is visible. * false: The annotation isn't visible. {#GF-getAnnotations__ul_z2j_4tl_rfc} Data type: Boolean |
[Table 48. Returns]

{#GF-getAnnotations__table_irm_qnl_rfc}  
The following example first calls getAnnotations() to return all annotations in a form, and then calls hideAnnotation() to hide all annotations in the form.

    const annotations = getAnnotations();

    /* returns:  
    [ 
        { 
            "name": "test-annotation-msg-1", 
            "visible": true, 
            "content": "Test<input id=\"make_spacing_ok\" style=\"visibility:hidden; width:0px;\">" 
        }, 
        { 
            "name": "test-annotation-msg-2", 
            "visible": true, 
            "content": "Test 2<input id=\"make_spacing_ok\" style=\"visibility:hidden; width:0px;\">" 
        } 

    ]*/
    annotations.forEach(function(annotation) {
    	g_form.hideAnnotation(annotation.name);
    });

    // this script hides all annotations on the form.

## GlideForm - getBooleanValue(String fieldName) {#ariaid-title26}

Returns a Boolean value for the specified field.
{#r_GlideFormGetBooleanValue_String__table_vfk_25b_5s__entry__3}{#r_GlideFormGetBooleanValue_String__g_form-getBooleanValue-fieldName-entry}

| Name | Type | Description |
|-|-|-|
| fieldName | String | Field to highlight in the following format: `"<table-name>.<field-name>"`. |
[Table 49. Parameters]

{#r_GlideFormGetBooleanValue_String__table_vfk_25b_5s} {#r_GlideFormGetBooleanValue_String__table_wfk_25b_5s__entry__2}

| Type | Description |
|-|-|
| Boolean | Returns false if the field value is false or undefined; otherwise returns true. |
[Table 50. Returns]

{#r_GlideFormGetBooleanValue_String__table_wfk_25b_5s}

## GlideForm - getChoice(String fieldName, String choiceValue) {#ariaid-title27}

Returns an object with properties representing a given field and choice value.
{#GF-getChoice_S_S__table_evm_xbs_rfc__entry__3}

| Name | Type | Description |
|-|-|-|
| fieldName | String | Field name of the choice to retrieve. |
| choiceValue | String | Value of the choice to retrieve. |
[Table 51. Parameters]

{#GF-getChoice_S_S__table_evm_xbs_rfc} {#GF-getChoice_S_S__table_fvm_xbs_rfc__entry__2}

| Property | Description |
|-|-|
| GlideFormChoice object or null | GlideFormChoice object for the specified field and choice value. Returns null if no matching choice exists. Data type: Object ("label", "value", "disabled", "index") |
| GlideFormChoice.label | Read-only display text of the choice. Data type: String |
| GlideFormChoice.value | Read-only value of the choice. Data type: String |
| GlideFormChoice.disabled | Flag that indicates whether the choice is disabled in the form. Valid values: * true: Choice is disabled * false: Choice is enabled. {#GF-getChoice_S_S__ul_xzv_rbz_tfc} Data type: Boolean |
| GlideFormChoice.index | Indicates the position of the choice in the drop-down. Data type: Number |
[Table 52. Returns]

{#GF-getChoice_S_S__table_fvm_xbs_rfc}  
The following example calls enable() to enable a new drop-down choice, `1`, in the `priority` form field.

    var shortDescription = g_form.getValue('shortDescription');

    // Allow priority 1 selection if short description mentions security 
    if (shortDescription.includes('security')) {
    	var p1Choice = g_form.getChoice('priority', '1');
    	g_form.enableChoice('priority', '1');
    }

## GlideForm - getControl(String fieldName) {#ariaid-title28}

Returns the HTML element for the specified field.
Compound fields may contain several HTML elements. This method is generally not necessary
as there are built-in methods that use the fields on a form.

If the field is a reference field and the control is a choice list,
getControl() may not return a control as expected. In this case, use
`sys_select.<table name>.<field name>`.

This method is not available in mobile scripts or Service Portal scripts.
{#r_GlideFormGetControl_String__table_lzt_x5b_5s__entry__3}{#r_GlideFormGetControl_String__g_form-getControl-fieldName-entry}

| Name | Type | Description |
|-|-|-|
| fieldName | String | Name of the field for which to return the HTML element. |
[Table 53. Parameters]

{#r_GlideFormGetControl_String__table_lzt_x5b_5s} {#r_GlideFormGetControl_String__table_mzt_x5b_5s__entry__2}{#r_GlideFormGetControl_String__g_form-getControl-returns-HTMLElement-entry}

| Type | Description |
|-|-|
| HTMLElement | Field's HTML element. |
[Table 54. Returns]

{#r_GlideFormGetControl_String__table_mzt_x5b_5s}

## GlideForm - getDecimalValue(String fieldName) {#ariaid-title29}

Returns the decimal value of the specified field.
{#r_GlideFormGetDecimalValue_String__table_izt_31c_5s__entry__3}{#r_GlideFormGetDecimalValue_String__g_form-getDecimalValue-fieldName-entry}

| Name | Type | Description |
|-|-|-|
| fieldName | String | Name of the field for which to return the decimal value. |
[Table 55. Parameters]

{#r_GlideFormGetDecimalValue_String__table_izt_31c_5s} {#r_GlideFormGetDecimalValue_String__table_jzt_31c_5s__entry__2}

| Type | Description |
|-|-|
| String | Decimal value of the specified field. |
[Table 56. Returns]

{#r_GlideFormGetDecimalValue_String__table_jzt_31c_5s}  

    function onChange(control, oldValue, newValue, isLoading) {
       alert(g_form.getDecimalValue('percent_complete'));
    }

## GlideForm - getDisplayBox(String fieldName) {#ariaid-title30}

Returns the display value from a form in the core UI.
Note:  
To get a display value from a form in Service Portal, use the [getDisplayValue()](https://www.servicenow.com/docs/HNdDSrkfvw56bJr9GUeUlA#GF-getDisplayValue_S "Returns the display value from a form in Service Portal.") method.  
See also:

* [getValue()](https://www.servicenow.com/docs/HNdDSrkfvw56bJr9GUeUlA#r_GlideFormGetValue_String "Returns the value of the specified form field.")
* [Get the display value of a reference
  variable](https://www.servicenow.com/community/developer-blog/get-display-value-of-reference-variable-service-catalog/ba-p/2287763)
{#GF-getDisplayBox_S__ul_djx_h4g_cvb}
{#GF-getDisplayBox_S__table_nf2_bfp_zw__entry__3}

| Name | Type | Description |
|-|-|-|
| fieldName | String |   |
[Table 57. Parameters]

{#GF-getDisplayBox_S__table_nf2_bfp_zw} {#GF-getDisplayBox_S__table_ydf_qpc_5s__entry__2}

| Type | Description |
|-|-|
| None | Name of the field from which to retrieve the value in the form. |
[Table 58. Returns]

{#GF-getDisplayBox_S__table_ydf_qpc_5s}  

    var caller = g_form.getDisplayBox('caller_id').value;

    var assignee = g_form.getDisplayBox('assigned_to').value;

    if (caller == assignee)
    {
       alert('in');
    }

## GlideForm - getDisplayValue(String fieldName) {#ariaid-title31}

Returns the display value from a form in Service Portal.
See also:

* [getValue()](https://www.servicenow.com/docs/HNdDSrkfvw56bJr9GUeUlA#r_GlideFormGetValue_String "Returns the value of the specified form field.")
* [Get the display value of a reference
  variable](https://www.servicenow.com/community/developer-blog/get-display-value-of-reference-variable-service-catalog/ba-p/2287763)
{#GF-getDisplayValue_S__ul_djx_h4g_cvb}  
Note:  
In the core UI, calling this method as `g_form.getDisplayValue()` without an argument returns the record display value rather than the display value of an individual field.
{#GF-getDisplayValue_S__table_nf2_bfp_zw__entry__3}{#GF-getDisplayValue_S__g_form-getDisplayValue-fieldName-entry}

| Name | Type | Description |
|-|-|-|
| fieldName | String | Name of the field from which you want to retrieve a value in the form. |
[Table 59. Parameters]

{#GF-getDisplayValue_S__table_nf2_bfp_zw} {#GF-getDisplayValue_S__table_ydf_qpc_5s__entry__2}

| Type | Description |
|-|-|
| String | Display value of the specified field. |
[Table 60. Returns]

{#GF-getDisplayValue_S__table_ydf_qpc_5s}  
The following example shows how to get the display value of a reference variable in the
core UI or Service Portal. The use case for this example is on the [community](https://www.servicenow.com/community/developer-blog/get-display-value-of-reference-variable-service-catalog/ba-p/2287763) site.

    function onChange(control, oldValue, newValue, isLoading) {
         if (isLoading || newValue == '') {
              return;
         }
         if(window == null){
              var valuePortal = g_form.getDisplayValue('requester');
              alert('Portal->' + valuePortal);
         }
         else{
              var valueNative = g_form.getDisplayBox('requester').value;     
              alert('CoreUI->' + valueCoreUI);
         }
         //Type appropriate comment here, and begin script below
    }

## GlideForm - getElement(String id) {#ariaid-title32}

Returns the HTML element specified by the parameter.
Compound fields may contain several HTML elements. This method is generally not necessary
as there are built-in methods that use the fields on a form.

This method is not available in mobile scripts or Service Portal scripts.
{#r_GlideFormGetElement_String__table_l1k_vvb_5s__entry__3}{#r_GlideFormGetElement_String__g_form-getElement-id-entry}

| Name | Type | Description |
|-|-|-|
| id | String | Field ID. |
[Table 61. Parameters]

{#r_GlideFormGetElement_String__table_l1k_vvb_5s} {#r_GlideFormGetElement_String__table_m1k_vvb_5s__entry__2}{#r_GlideFormGetElement_String__g_form-getElement-returns-HTMLElement-entry}

| Type | Description |
|-|-|
| HTMLElement | Field's HTML element. |
[Table 62. Returns]

{#r_GlideFormGetElement_String__table_m1k_vvb_5s}

## GlideForm - getFormElement() {#ariaid-title33}

Returns the HTML element for the form.
This method is not available in mobile scripts or Service Portal scripts.
{#r_GlideFormGetFormElement__table_fs4_kkd_5s__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 63. Parameters]

{#r_GlideFormGetFormElement__table_fs4_kkd_5s} {#r_GlideFormGetFormElement__table_gs4_kkd_5s__entry__2}{#r_GlideFormGetFormElement__g_form-getFormElement-returns-HTMLElement-entry}

| Type | Description |
|-|-|
| HTMLFormElement | HTML element for the form. |
[Table 64. Returns]

{#r_GlideFormGetFormElement__table_gs4_kkd_5s}

## GlideForm - getHelpTextControl(String fieldName) {#ariaid-title34}

Returns the HTML element of the help text for the specified field.
This method is applicable to service catalog variables only.
{#r_GF-getHelpTextControl_S__table_nf2_bfp_zw__entry__3}

| Name | Type | Description |
|-|-|-|
| fieldName | String | Name of the field. |
[Table 65. Parameters]

{#r_GF-getHelpTextControl_S__table_nf2_bfp_zw} {#r_GF-getHelpTextControl_S__table_of2_bfp_zw__entry__2}

| Type | Description |
|-|-|
| HTMLElement | Help text field's HTML element. |
[Table 66. Returns]

{#r_GF-getHelpTextControl_S__table_of2_bfp_zw}

## GlideForm - getIntValue(String fieldName) {#ariaid-title35}

Returns the integer value for the specified field.
{#r_GlideFormGetIntValue_String__table_unc_nwb_5s__entry__3}{#r_GlideFormGetIntValue_String__g_form-getIntValue-fieldName-entry}

| Name | Type | Description |
|-|-|-|
| fieldName | String | Field name. |
[Table 67. Parameters]

{#r_GlideFormGetIntValue_String__table_unc_nwb_5s} {#r_GlideFormGetIntValue_String__table_vnc_nwb_5s__entry__2}{#r_GlideFormGetIntValue_String__g_form-getIntValue-returns-entry}

| Type | Description |
|-|-|
| Number | Integer value of the field. |
[Table 68. Returns]

{#r_GlideFormGetIntValue_String__table_vnc_nwb_5s}

## GlideForm - getLabelOf(String fieldName) {#ariaid-title36}

Returns the plain text value of the field label.
{#r_GlideFormGetLabelOf_String__table_gfz_kgw_ts__entry__3}{#r_GlideFormGetLabelOf_String__g_form-getLabelOf-fieldName-entry}

| Name | Type | Description |
|-|-|-|
| fieldName | String | Field name. |
[Table 69. Parameters]

{#r_GlideFormGetLabelOf_String__table_gfz_kgw_ts} {#r_GlideFormGetLabelOf_String__table_hfz_kgw_ts__entry__2}{#r_GlideFormGetLabelOf_String__g_form-getLabelOf-returns-entry}

| Type | Description |
|-|-|
| String | Label text. |
[Table 70. Returns]

{#r_GlideFormGetLabelOf_String__table_hfz_kgw_ts}  

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

## GlideForm - getOption(String fieldName, String choiceValue) {#ariaid-title37}

Returns the option element for a selected box named fieldName
where choiceValue matches the option value.
Note:  
This method does not work on read-only fields.
{#r_GlideFormGetOption_String_String__table_u1p_1xb_5s__entry__3}

| Name | Type | Description |
|-|-|-|
| fieldName | String | Name of the field. |
| choiceValue | String | Value of the option. |
[Table 71. Parameters]

{#r_GlideFormGetOption_String_String__table_u1p_1xb_5s} {#r_GlideFormGetOption_String_String__table_v1p_1xb_5s__entry__2}

| Type | Description |
|-|-|
| HTMLElement | The HTMLElement for the option. Returns null if the field or option is not found. |
[Table 72. Returns]

{#r_GlideFormGetOption_String_String__table_v1p_1xb_5s}  
The following example shows how to get the label for a choice list value.

    // Get the label for a choice list value
    // fieldName is 'category'
     
    function onChange(control, oldValue, newValue, isLoading) {
    var choiceValue = g_form.getValue('category');
    var choiceLabel = g_form.getOption('category', choiceValue).text; 
    }

## GlideForm - getOptions(String fieldName) {#ariaid-title38}

Returns the available and selected options for a choice or reference field on the form. This method is useful for dynamic forms, catalog variables and variable sets, and integrations needing to inspect or filter field options at runtime.
For example, you can use the g_form.getOptions() to:  
* Get and set the name-value pairs in a watch_list field type.
* Search or filter available options by a search term.
* Enable access to the same auto-complete results via a callback.
* Get and set options on choice fields, reference fields, and advanced field types such as watch_list, glide_list, field_list, and slushbucket.
{#GF-getOptions_S__ul_rgd_24f_wfc}
{#GF-getOptions_S__table_dz3_jyr_rfc__entry__3}

| Name | Type | Description |
|-|-|-|
| fieldName | String | The field name of the choice or reference field to retrieve. |
[Table 73. Parameters]

{#GF-getOptions_S__table_dz3_jyr_rfc} {#GF-getOptions_S__table_ez3_jyr_rfc__entry__2}

| Property | Description |
|-|-|
| Array of Objects or null | Read-only array of objects containing the value and label of each selected option. Returns null if the field does not support options. Data type: Array of Objects [{value: "String", displayValue: "String"}] |
| array.displayValue | The choice display value. Data type: String |
| array.value | The value of the option. Data type: String |
| getAvailable(term) | Function for returning all available options. A search term can be provided as an argument to filter the options by display value (a case-insensitive sub string match). Returns a Promise of Array of Objects with the matching choice's display value and value. Data type: Array of Objects [{value: "String", displayValue: "String"}] |
[Table 74. Returns]

{#GF-getOptions_S__table_ez3_jyr_rfc}  
The following example calls g_form.getOptions() to return all available choices for specified form fields, like state, work_notes_list, and others.

    g_form.getOptions("state"); //table: incident, field: state, type: integer, choice: Dropdown without --None--
    /*
    returns [{"value":"1","displayValue":"New"},{"value":"2","displayValue":"In Progress"},{"value":"3","displayValue":"On Hold"},{"value":"6","displayValue":"Resolved"},{"value":"7","displayValue":"Closed"},{"value":"8","displayValue":"Canceled"}]
    */

    g_form.getOptions("category"); //table: incident, field: category, type: string, choice: Dropdown with --None--
    /*
    returns [{"value":"","displayValue":"-- None --"},{"value":"inquiry","displayValue":"Inquiry / Help"},{"value":"software","displayValue":"Software"},{"value":"hardware","displayValue":"Hardware"},{"value":"network","displayValue":"Network"},{"value":"database","displayValue":"Database"}]
    */

    g_form.getOptions("work_notes_list") //table: incident, field: work_notes_list, type: glide_list
    /*
    returns [{"value":"62826bf03710200044e0bfc8bcbe5df1","displayValue":"Abel Tuter"},{"value":"a8f98bb0eb32010045e1a5115206fe3a","displayValue":"Abraham Lincoln"},{"value":"5137153cc611227c000bbd1bd8cd2005","displayValue":"Fred Luddy"},{"value":"6a826bf03710200044e0bfc8bcbe5dec","displayValue":"Alissa Mountjoy"}]
    */

    g_form.getOptions("restricted_fields") //table: std_change_properties, field: restricted_fields, type: field_list
    /*
    [{"value":"activity_due","displayValue":"Activity due"},{"value":"additional_assignee_list","displayValue":"Additional assignee list"},{"value":"comments","displayValue":"Additional comments"},{"value":"assignment_group","displayValue":"Assignment group"},{"value":"backout_plan","displayValue":"Backout plan"},{"value":"business_duration","displayValue":"Business duration"},{"value":"cab_delegate","displayValue":"CAB delegate"},...]
    */

    g_form.getOptions('table') //table: sys_script_client, field: table, type: table_name
    /*
    [{"value":"","displayValue":"-- None --"},{"value":"cmdb_ci_appl_dot_net","displayValue":".NET Application [cmdb_ci_appl_dot_net]"},{"value":"evaluation","displayValue":"A/B Testing Evaluation [evaluation]"},{"value":"evaluation_execution","displayValue":"A/B Testing Evaluation Execution [evaluation_execution]"},{"value":"evaluation_parameter","displayValue":"A/B Testing Evaluation Parameter [evaluation_parameter]"},{"value":"sn_access_analyzer_request","displayValue":"Access Analyzer Query [sn_access_analyzer_request]"},{"value":"sn_access_analyzer_access_comparison_request","displayValue":"Access Comparison Request [sn_access_analyzer_access_comparison_request]"},{"value":"sys_security_acl","displayValue":"Access Control [sys_security_acl]"},...]
    */

    g_form.getOptions('mandatory_fields'); //table: kb_knowledge_base, field: mandatory_fields, type: slushbucket
    /*
    [{"value":"active","displayValue":"Active"},{"value":"article_id","displayValue":"Article ID"},{"value":"displayValue","displayValue":"Article body"},{"value":"article_type","displayValue":"Article type"},{"value":"direct","displayValue":"Attachment link"},{"value":"author","displayValue":"Author"},{"value":"base_version","displayValue":"Base Version"},...]
    */

The following example script demonstrates how to call g_form.getOptions() with getAvailable() function.

    const options = g_form.getOptions('priority');
    if (options) {
      console.log('Selected:', options.selected);
      options.getAvailable('high').then(available => {
        console.log('Available matching "high":', available);
      });
    }

## GlideForm - getReference(String fieldName, Function callBack) {#ariaid-title39}

Returns the GlideRecord for a specified field.
If a callback function is present, this routine runs asynchronously. The browser (and
script) processing continues normally until the server returns the reference value, at which
time, the callback function is invoked. If a callback function is not present, this routine
runs synchronously and processing halts (causing the browser to appear to hang) while
waiting on a server response.  
Important:  
It is strongly recommended that you use a callback function.

Callback function support for ServiceCatalogForm.getReference is available.  
Note:  
Using this method requires a call to the server which requires additional time and may introduce latency to your page. Use this method with caution. For additional information, see [Client script design and
processing](https://www.servicenow.com/docs/qAVWIyId3mVVD2utwHIhYA#client-script-best-practices "Well-designed client scripts can reduce the amount of time it takes users to complete a form.").
{#r_GlideForm-GetReference_S_F__table_k4c_1yb_5s__entry__3}{#r_GlideForm-GetReference_S_F__g_form-getReference-fieldName-entry}{#r_GlideForm-GetReference_S_F__g_form-getReference-callBack-entry}

| Name | Type | Description |
|-|-|-|
| fieldName | String | Name of the field. |
| callBack | Function | Name of the call back function. |
[Table 75. Parameters]

{#r_GlideForm-GetReference_S_F__table_k4c_1yb_5s} {#r_GlideForm-GetReference_S_F__table_l4c_1yb_5s__entry__2}{#r_GlideForm-GetReference_S_F__g_form-getReference-returns-entry}

| Type | Description |
|-|-|
| GlideRecord | GlideRecord object for the specified field. If the specified reference can't be found, it returns an initialized GlideRecord object where `currentRow = -1` and `rows.length = 0`. |
[Table 76. Returns]

{#r_GlideForm-GetReference_S_F__table_l4c_1yb_5s}  

    function onChange(control, oldValue, newValue, isLoading) {
        g_form.getReference('caller_id', doAlert); // doAlert is our callback function
    }
     
    function doAlert(caller) { // reference is passed into callback as first arguments
       if (caller.getValue('vip') == 'true') {
          alert('Caller is a VIP!');
       }
    }

## GlideForm - getRelatedListNames() {#ariaid-title40}

Returns an array of related list names from the current form.
{#GF-getRelatedListNames__table_vfp_grv_dhb__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 77. Parameters]

{#GF-getRelatedListNames__table_vfp_grv_dhb} {#GF-getRelatedListNames__table_wfp_grv_dhb__entry__2}{#GF-getRelatedListNames__g_form-getRelatedListNames-returns-entry}

| Type | Description |
|-|-|
| Array of Strings | List of related list names from the current form. The related list names are listed in the order in which they appear on the form. |
[Table 78. Returns]

{#GF-getRelatedListNames__table_wfp_grv_dhb}  

    var listNames = g_form.getRelatedListNames();

    for (var i = 0; i < listNames.length; i++) {  
      this.showRelatedList(listNames[i]);
     }

## GlideForm - getSectionNames() {#ariaid-title41}

Returns all section names, whether visible or not.
{#r_GlideFormGetSectionNames__table_rsg_vkd_5s__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 79. Parameters]

{#r_GlideFormGetSectionNames__table_rsg_vkd_5s} {#r_GlideFormGetSectionNames__table_ssg_vkd_5s__entry__2}{#r_GlideFormGetSectionNames__g_form-getSectionNames-returns-entry}

| Type | Description |
|-|-|
| Array of Strings | Section names. |
[Table 80. Returns]

{#r_GlideFormGetSectionNames__table_ssg_vkd_5s}

## GlideForm - getSections() {#ariaid-title42}

Returns an array of the form's sections.
This method is not available on the mobile platform. If this method is run on a mobile
platform, no action occurs.
{#r_GlideFormGetSections__table_sg4_hld_5s__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 81. Parameters]

{#r_GlideFormGetSections__table_sg4_hld_5s} {#r_GlideFormGetSections__table_tg4_hld_5s__entry__2}{#r_GlideFormGetSections__g_form-getSections-returns-entry}

| Type | Description |
|-|-|
| Array of HTML elements | Form's sections. |
[Table 82. Returns]

{#r_GlideFormGetSections__table_tg4_hld_5s}  

    function onChange(control, oldValue, newValue, isLoading) {
       //this example was run on a form divided into sections (Change form)
       // and hid a section when the "state" field was changed
       var sections = g_form.getSections();
       if (newValue == '2') {
          g_form.setSectionDisplay(sections[1], false);
       } else {
          g_form.setSectionDisplay(sections[1], true);
       }
    }

## GlideForm - getTableName() {#ariaid-title43}

Returns the name of the table to which this record belongs.
On the server side, the table for the current record can be retrieved with
current.sys_class_name or
current.getTableName().
{#r_GlideFormGetTableName__table_gqk_5ld_5s__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 83. Parameters]

{#r_GlideFormGetTableName__table_gqk_5ld_5s} {#r_GlideFormGetTableName__table_hqk_5ld_5s__entry__2}{#r_GlideFormGetTableName__g_form-getTableName-returns-entry}

| Type | Description |
|-|-|
| String | Name of the table. |
[Table 84. Returns]

{#r_GlideFormGetTableName__table_hqk_5ld_5s}  

    function onLoad() {
        if (g_form.isNewRecord()) {
            var tableName = g_form.getTableName(); //Get the table name
        }
    }

## GlideForm - getUniqueValue() {#ariaid-title44}

Returns the sys_id of the record displayed in the form.
{#r_GlideFormGetUniqueValue__table_xxg_lmd_5s__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 85. Parameters]

{#r_GlideFormGetUniqueValue__table_xxg_lmd_5s} {#r_GlideFormGetUniqueValue__table_yxg_lmd_5s__entry__2}{#r_GlideFormGetUniqueValue__g_form-getUniqueValue-returns-entry}

| Type | Description |
|-|-|
| String | Record's sys_id. |
[Table 86. Returns]

{#r_GlideFormGetUniqueValue__table_yxg_lmd_5s}  

    function onLoad() {
       var incSysid = g_form.getUniqueValue();
       alert(incSysid);
    }

## GlideForm - getValue(String fieldName) {#ariaid-title45}

Returns the value of the specified form field.
This method also supports getting values from a multi-row variable set (MRVS). To obtain data from fields within an MRVS, you must first use `JSON.parse(getValue('<mrvs_field_name>') || '[]')` to obtain the
MRVS array, and then use indexing to access the fields within the row objects. For more details, see the code example below.
{#r_GlideFormGetValue_String__table_nxm_wzb_5s__entry__3}{#r_GlideFormGetValue_String__g_form-getValue-fieldName-entry}

| Name | Type | Description |
|-|-|-|
| fieldName | String | Name of the field whose value to return. |
[Table 87. Parameters]

{#r_GlideFormGetValue_String__table_nxm_wzb_5s} {#r_GlideFormGetValue_String__table_oxm_wzb_5s__entry__2}{#r_GlideFormGetValue_String__g_form-getValue-returns-entry}

| Type | Description |
|-|-|
| String | Value of the specified field. |
[Table 88. Returns]

{#r_GlideFormGetValue_String__table_oxm_wzb_5s}  
The following example shows how to get the short description from the current form.

    function onChange(control, oldValue, newValue, isLoading) {
       alert(g_form.getValue('short_description'));
    }

The following example shows how to get values from an MRVS. In this example, salaries are being managed through the Service Catalog. The client script searches all rows within the MRVS for the value entered in the Job title and then updates the matching entries within the MRVS with what is entered in the Salary field. The MRVS is named "variable_set_1" and contains the following fields within each row
object: Employee name \[employee_name\], Job title \[employee_job_title\], and Salary \[employee_salary\]. In addition, the Catalog Item contains: Job title \[job_title\] and Salary \[salary\].

    function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
    return;
    }
     
    // Get the MRVS
    var vs1 = g_form.getValue('variable_set_1') || '[]';
    var multiRowVariableSet = JSON.parse(vs1);
     
    for (var i = 0; i < multiRowVariableSet.length; i++) {
    // Check if the entered job title matches the title in the current MRVS row
      if (multiRowVariableSet[i].employee_job_title == g_form.getValue("job_title")){
        // Update the value of a matching field with the new salary
        multiRowVariableSet[i].employee_salary = newValue;
      }
    }
     
    // Update the MRVS
    g_form.setValue('variable_set_1', JSON.stringify(multiRowVariableSet));
    }

## GlideForm - hideAllFieldMsgs() {#ariaid-title46}

Hides all field messages.
{#r_GlideFormHideAllFieldMsgs__table_mr1_3hw_ts__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 89. Parameters]

{#r_GlideFormHideAllFieldMsgs__table_mr1_3hw_ts} {#r_GlideFormHideAllFieldMsgs__table_nr1_3hw_ts__entry__2}

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

{#r_GlideFormHideAllFieldMsgs__table_nr1_3hw_ts}

## GlideForm - hideAllFieldMsgs(String type) {#ariaid-title47}

Hides all field messages of the specified type.
{#r_GlideFormHideAllFieldMsgs_String__table_y2c_qhw_ts__entry__3}{#r_GlideFormHideAllFieldMsgs_String__g_form-hideAllFieldMsgs_S-type-entry}

| Name | Type | Description |
|-|-|-|
| type | String | \>Type of message. Valid values: * error * info {#r_GlideFormHideAllFieldMsgs_String__ul_rgd_sqg_5fc} |
[Table 91. Parameters]

{#r_GlideFormHideAllFieldMsgs_String__table_y2c_qhw_ts} {#r_GlideFormHideAllFieldMsgs_String__table_z2c_qhw_ts__entry__2}

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

{#r_GlideFormHideAllFieldMsgs_String__table_z2c_qhw_ts}

## GlideForm - hideAnnotation(String name) {#ariaid-title48}

Hides an annotation with a given name on the form UI.
[Annotations](https://www.servicenow.com/docs/access?context=configure-form-layout&version=australia&pubname=australia-platform-administration&section=t_AddAFormAnnotation&ft:locale=en-US) are visual separators between form elements, or blocks of colored text used to highlight form elements. See also:

* [GlideForm - showErrorBox(String name, String message, Boolean scrollForm)](https://www.servicenow.com/docs/HNdDSrkfvw56bJr9GUeUlA#r_GF-ShowErrorBox_S_S_B "Displays an error message under the specified form field (either a control object or the name of the field). If the control or field is currently off the screen and the scrollForm parameter is true, the form scrolls to the control or field.") to display a specific annotation on the form.
* [GlideForm - toggleAnnotations()](https://www.servicenow.com/docs/HNdDSrkfvw56bJr9GUeUlA#GF-toggleAnnotations "Hides or shows all annotations on the form.") to toggle annotations on and off with greater flexibility.
{#GF-hideAnnotation_S__ul_iqn_jmf_wfc}
{#GF-hideAnnotation_S__table_isv_1nt_rfc__entry__3}

| Name | Type | Description |
|-|-|-|
| name | String | Name of the annotation to hide in the form. Table: Form Annotations \[sys_ui_annotation\], Field: Name |
[Table 93. Parameters]

{#GF-hideAnnotation_S__table_isv_1nt_rfc} {#GF-hideAnnotation_S__table_ovh_cnt_rfc__entry__2}

| Type | Description |
|-|-|
| None |   |
[Table 94. Returns]

{#GF-hideAnnotation_S__table_ovh_cnt_rfc}  
The following example demonstrates how to programmatically hide the annotation named test-annotation-msg-1 on the form field using the hideAnnotation() method.

    g_form.hideAnnotation('test-annotation-msg-1');

## GlideForm - hideErrorBox(String fieldName) {#ariaid-title49}

Hides the error message placed by showErrorBox().
Whenever possible, use hideFieldMsg() rather than this method whenever
possible.
{#r_GlideFormHideErrorBox_String__table_kll_t4w_ts__entry__3}{#r_GlideFormHideErrorBox_String__g_form-hideErrorBox-fieldName-entry}

| Name | Type | Description |
|-|-|-|
| fieldName | String | Name of the field or control whose error message to hide. |
[Table 95. Parameters]

{#r_GlideFormHideErrorBox_String__table_kll_t4w_ts} {#r_GlideFormHideErrorBox_String__table_lll_t4w_ts__entry__2}

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

{#r_GlideFormHideErrorBox_String__table_lll_t4w_ts}

## GlideForm - hideFieldMsg(String fieldName, Boolean clearAll) {#ariaid-title50}

Hides the first message that appears in the specified field on the current form.
Use the [GlideForm - showFieldMsg(String field, String message, String type)](https://www.servicenow.com/docs/HNdDSrkfvw56bJr9GUeUlA#r_GF-ShowFieldMsg_S_S_S "Displays a message under the specified form field (either a control object or the name of the field). If the control or field is off the screen, the method automatically scrolls the form to that field.") or [GlideForm - showFieldMsg(String field, String message, String type, Boolean scrollForm)](https://www.servicenow.com/docs/HNdDSrkfvw56bJr9GUeUlA#r_GF-ShowFieldMsg_S_S_S_B "Displays a message under the specified form field (either a control object or the name of the field). If the control or field is currently off the screen and scrollForm is true, the method scrolls the form to that field.") methods to display messages on a form.  
For example, the following code snippet shows how to display two messages on the `work_notes` field of a form and then hide the first message:

    g_form.showFieldMsg('work_notes', 'First message', "error");
    g_form.showFieldMsg('work_notes', 'Second message', "error");
    g_form.hideFieldMsg('work_notes', false); // This call hides the 'First message'

{#r_GlideFormHideFieldMsg_String__table_xnf_3pw_ts__entry__3}{#r_GlideFormHideFieldMsg_String__g_form-hideFieldMsg-fieldName-entry}{#r_GlideFormHideFieldMsg_String__g_form-hideFieldMsg-clearAll-entry}

| Name | Type | Description |
|-|-|-|
| fieldName | String | Name of the field on which to hide the message. |
| clearAll | Boolean | Optional. Flag that indicates whether to hide all messages for the specified field. Valid values: * true: Hide all messages. * false: Only hide the first message being displayed. {#r_GlideFormHideFieldMsg_String__ul_add_sqg_5fc} Default: false |
[Table 97. Parameters]

{#r_GlideFormHideFieldMsg_String__table_xnf_3pw_ts} {#r_GlideFormHideFieldMsg_String__table_ynf_3pw_ts__entry__2}

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

{#r_GlideFormHideFieldMsg_String__table_ynf_3pw_ts}  
The following example shows how to clear all messages for a specified form field and then display an encryption error message.

    function submitEncryptedInputs() {
      return processEncryptedInputs(function(inputName, fieldName) {
        if (!checkEncryptedFieldValue(fieldName)) {
          g_form.hideFieldMsg(fieldName, true); // Hide all messages for the specified field
          g_form.showFieldMsg(fieldName, "Your activity requires an encrypted input.", "error");
          return false;
        }
        return true;
      });
    }

## GlideForm - hideRelatedLinks() {#ariaid-title51}

Hides the Related Links section of a form.
See also:

* [GlideForm - showRelatedLinks()](https://www.servicenow.com/docs/HNdDSrkfvw56bJr9GUeUlA#GF-showRelatedLinks "Displays the Related Links section of a form.")
* [GlideForm - setRelatedLinksDisplay(Boolean display)](https://www.servicenow.com/docs/HNdDSrkfvw56bJr9GUeUlA#GF-setRelatedLinksDisplay_B "Show or hide the Related Links section in the form UI using Boolean values.")
{#GF-hideRelatedLinks__ul_lbh_5hq_vfc}
{#GF-hideRelatedLinks__table_zn5_jzs_rfc__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 99. Parameters]

{#GF-hideRelatedLinks__table_zn5_jzs_rfc} {#GF-hideRelatedLinks__table_a45_jzs_rfc__entry__2}

| Type | Description |
|-|-|
| None |   |
[Table 100. Returns]

{#GF-hideRelatedLinks__table_a45_jzs_rfc}  
The following example script hides related links in the current form.

    // Hide related links
    g_form.hideRelatedLinks()

## GlideForm - hideRelatedList(String listTableName) {#ariaid-title52}

Hides the specified related list on the form.
This method is not available on the mobile platform. If this method is run on a mobile
platform, no action occurs.
{#r_GlideFormHideRelatedList_String__table_syn_wqw_ts__entry__3}{#r_GlideFormHideRelatedList_String__g_form-hideRelatedList-listTableName-entry}

| Name | Type | Description |
|-|-|-|
| listTableName | String | Name of the related list. Use the sys_id to hide a list through a relationship. |
[Table 101. Parameters]

{#r_GlideFormHideRelatedList_String__table_syn_wqw_ts} {#r_GlideFormHideRelatedList_String__table_tyn_wqw_ts__entry__2}

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

{#r_GlideFormHideRelatedList_String__table_tyn_wqw_ts}

## GlideForm - hideRelatedLists() {#ariaid-title53}

Hides all related lists on the form.
This method is not available on the mobile platform. If this method is run on a mobile
platform, no action occurs.
{#r_GlideFormHideRelatedLists__table_zmg_jrw_ts__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 103. Parameters]

{#r_GlideFormHideRelatedLists__table_zmg_jrw_ts} {#r_GlideFormHideRelatedLists__table_ang_jrw_ts__entry__2}

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

{#r_GlideFormHideRelatedLists__table_ang_jrw_ts}

## GlideForm - hideTemplateBar() {#ariaid-title54}

Hides the template bar on the form.
{#GF-hideTemplateBar__table_ivb_s5g_5fc__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 105. Parameters]

{#GF-hideTemplateBar__table_ivb_s5g_5fc} {#GF-hideTemplateBar__table_jvb_s5g_5fc__entry__2}

| Type | Description |
|-|-|
| None |   |
[Table 106. Returns]

{#GF-hideTemplateBar__table_jvb_s5g_5fc}  
The following example script hides the Template Bar on the current form.

    g_form.hideTemplateBar()

## GlideForm - isLiveUpdating() {#ariaid-title55}

Returns true while a live update is being done on the record the form is showing.
This can be used in an onChange() client script to determine if a change
to the record is because of a live update from another session. The client script can then
decide what action to take, or not to take. This applies to systems using Core UI with live forms enabled.
{#r_GF-isLiveUpdating__table_fjz_sks_kx__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 107. Parameters]

{#r_GF-isLiveUpdating__table_fjz_sks_kx} {#r_GF-isLiveUpdating__table_gjz_sks_kx__entry__2}{#r_GF-isLiveUpdating__g_form-isLiveUpdating-returns-entry}

| Type | Description |
|-|-|
| Boolean | Returns true if a live update is happening on the record displayed by the form. |
[Table 108. Returns]

{#r_GF-isLiveUpdating__table_gjz_sks_kx}

## GlideForm - isMandatory(String fieldName) {#ariaid-title56}

Returns true if the field is mandatory.
Mandatory fields are visually distinguished by an asterisk next to the field label. The asterisk is red if the field is empty, and black if the field is not empty. The system displays a
validation message if a user attempts to save or submit the form without completing those fields. For more information, see [Form fields](https://www.servicenow.com/docs/access?context=c_FormFields&version=australia&pubname=australia-platform-user-interface&ft:locale=en-US).
{#r_GlideFormIsMandatory_String__table_kpt_nnc_5s__entry__3}{#r_GlideFormIsMandatory_String__g_form-isMandatory-fieldName-entry}

| Name | Type | Description |
|-|-|-|
| fieldName | String | Name of the field. |
[Table 109. Parameters]

{#r_GlideFormIsMandatory_String__table_kpt_nnc_5s} {#r_GlideFormIsMandatory_String__table_lpt_nnc_5s__entry__2}{#r_GlideFormIsMandatory_String__g_form-isMandatory-returns-entry}

| Type | Description |
|-|-|
| Boolean | True if the field is required, false otherwise. |
[Table 110. Returns]

{#r_GlideFormIsMandatory_String__table_lpt_nnc_5s}

## GlideForm - isNewRecord() {#ariaid-title57}

Returns true if the record has never been saved.
{#r_GlideFormIsNewRecord__table_wlm_wmd_5s__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 111. Parameters]

{#r_GlideFormIsNewRecord__table_wlm_wmd_5s} {#r_GlideFormIsNewRecord__table_xlm_wmd_5s__entry__2}{#r_GlideFormIsNewRecord__g_form-isNewRecord-returns-entry}

| Type | Description |
|-|-|
| Boolean | Returns true if the record has not been saved; otherwise false. |
[Table 112. Returns]

{#r_GlideFormIsNewRecord__table_xlm_wmd_5s}  

    function onLoad() {
       if(g_form.isNewRecord()){
          alert('New Record!');
       }
    }

## GlideForm - isSectionVisible(String sectionName) {#ariaid-title58}

Returns true if the section is visible.
Important:  
The isSectionVisible() function is not supported in Workspace.
{#r_GlideFormIsSectionVisible_String__table_msy_jnd_5s__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 113. Parameters]

{#r_GlideFormIsSectionVisible_String__table_msy_jnd_5s} {#r_GlideFormIsSectionVisible_String__table_nsy_jnd_5s__entry__2}

| Type | Description |
|-|-|
| Boolean | Returns true when the section is visible; otherwise, false is returned. |
[Table 114. Returns]

{#r_GlideFormIsSectionVisible_String__table_nsy_jnd_5s}

## GlideForm - isVisible(String fieldName) {#ariaid-title59}

Determines whether the field associated with the passed-in field name is visible on the current form.
{#GF-isVisible_S__table_ps3_gqy_m2c__entry__3}{#GF-isVisible_S__g_form-isVisible-fieldName-entry}

| Name | Type | Description |
|-|-|-|
| fieldName | String | Name of the field to check whether it is visible on the current form. |
[Table 115. Parameters]

{#GF-isVisible_S__table_ps3_gqy_m2c} {#GF-isVisible_S__table_qs3_gqy_m2c__entry__2}{#GF-isVisible_S__g_form-isVisible-returns-entry}

| Type | Description |
|-|-|
| Boolean | Flag that indicates whether the specified field is visible on the current form. Possible values: * true: Field is visible on the form. * false: Field isn't visible on the form. {#GF-isVisible_S__ul_p1v_dhp_jfc} |
[Table 116. Returns]

{#GF-isVisible_S__table_qs3_gqy_m2c}  
The following code example shows how to check if the `user_address` field is visible on the current form.

    if(g_form.isVisible('user_address')) {
        alert('is visible');
    }
    else {
        alert('is hidden');
    }

## GlideForm - onUserChangeValue(Function fn) {#ariaid-title60}

Registers a custom event listener that detects when any field in the current form is modified by a user.
When a form field is modified, the event listener calls the function that is passed in when
the listener is initially registered. This listener is only triggered when a user makes a
change to a field on the form. Changes from client scripts, UI policies, or any other
non-user interactions, do not trigger the listener.  
Note:  
This method does not work for journal fields or Service Catalog items in the classic environment.
{#GF-onUserChangeValue_F__table_m5y_wll_1hb__entry__3}{#GF-onUserChangeValue_F__g_form-onUserChangeValue-fn-entry}

| Name | Type | Description |
|-|-|-|
| fn | Function | Function to call when a user changes the value of a field within the current form. This is actually the function code, not just the function name. This function must accept the following three arguments: * field name * original field value * updated field value {#GF-onUserChangeValue_F__ul_k2d_sqg_5fc} |
[Table 117. Parameters]

{#GF-onUserChangeValue_F__table_m5y_wll_1hb} {#GF-onUserChangeValue_F__table_n5y_wll_1hb__entry__2}{#GF-onUserChangeValue_F__g_form-onUserChangeValue-returns-entry}

| Type | Description |
|-|-|
| Function | Function to call to unregister the onUserChangeValue event listener. |
[Table 118. Returns]

{#GF-onUserChangeValue_F__table_n5y_wll_1hb}  

    var handler = function(fieldname, originalValue, newValue) {
      console.log('The field ('+ fieldname + ') has a new value of: ' + newValue); // function code
    }
     
    var unregister = g_form.onUserChangeValue(handler);
     
    // To unregister the event listener
    unregister();

## GlideForm - refreshSlushbucket(String fieldName) {#ariaid-title61}

You can update a list collector variable.
{#r_GF-refreshSlushbucket_S__table_n3v_plp_cv__entry__3}

| Name | Type | Description |
|-|-|-|
| fieldName | String | Name of the slush bucket. |
[Table 119. Parameters]

{#r_GF-refreshSlushbucket_S__table_n3v_plp_cv} {#r_GF-refreshSlushbucket_S__table_o3v_plp_cv__entry__2}

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

{#r_GF-refreshSlushbucket_S__table_o3v_plp_cv}  

    g_form.refreshSlushbucket('bucket');

## GlideForm - removeDecoration(String fieldname, String icon, String title) {#ariaid-title62}

Removes the icon from the specified field that matches the specified icon and title.
Note:  
This method isn't supported by Service Catalog.
{#r_GF-RemoveDecoration_S_S_S__table_x23_vrw_ts__entry__3}{#r_GF-RemoveDecoration_S_S_S__g_form-removeDecoration-fieldName-entry}{#r_GF-RemoveDecoration_S_S_S__g_form-removeDecoration-icon-entry}{#r_GF-RemoveDecoration_S_S_S__g_form-removeDecoration-title-entry}

| Name | Type | Description |
|-|-|-|
| fieldName | String | Field name from which to remove the decoration. |
| icon | String | Name of the icon to remove. |
| title | String | Icon's text title (name). |
[Table 121. Parameters]

{#r_GF-RemoveDecoration_S_S_S__table_x23_vrw_ts} {#r_GF-RemoveDecoration_S_S_S__table_y23_vrw_ts__entry__2}

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

{#r_GF-RemoveDecoration_S_S_S__table_y23_vrw_ts}  

    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');			
    	});
    }

## GlideForm - removeDecoration(String fieldname, String icon, String title, String
color) {#ariaid-title63}

Removes the icon from the specified field that matches the specified icon, title, and color.
Note:  
This method isn't supported by Service Catalog.
{#r_GF-RemoveDecoration_S_S_S_S__table_mcg_5zd_5s__entry__3}{#r_GF-RemoveDecoration_S_S_S_S__g_form-removeDecoration-fieldName-entry}{#r_GF-RemoveDecoration_S_S_S_S__g_form-removeDecoration-icon-entry}{#r_GF-RemoveDecoration_S_S_S_S__g_form-removeDecoration-title-entry}{#r_GF-RemoveDecoration_S_S_S_S__g_form-removeDecoration-color-entry}

| Name | Type | Description |
|-|-|-|
| fieldName | String | Field name from which to remove the decoration. |
| icon | String | Name of the icon to remove. |
| title | String | Icon's text title (name). |
| color | String | CSS color to match. |
[Table 123. Parameters]

{#r_GF-RemoveDecoration_S_S_S_S__table_mcg_5zd_5s} {#r_GF-RemoveDecoration_S_S_S_S__table_ncg_5zd_5s__entry__2}

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

{#r_GF-RemoveDecoration_S_S_S_S__table_ncg_5zd_5s}  

    g_form.removeDecoration('caller_id', 'icon-star', 'VIP', 'blue');

## GlideForm - removeOption(String fieldName, String choiceValue) {#ariaid-title64}

Removes the specified option from the specified choice list.
{#r_GlideFormRemoveOption_String_String__table_p4k_hjd_5s__entry__3}{#r_GlideFormRemoveOption_String_String__g_form-removeOption-fieldName-entry}{#r_GlideFormRemoveOption_String_String__g_form-removeOption-choiceValue-entry}

| Name | Type | Description |
|-|-|-|
| fieldName | String | Name of the field from which to remove the option from the choice list. |
| choiceValue | String | Value stored in the database. This is not the label. |
[Table 125. Parameters]

{#r_GlideFormRemoveOption_String_String__table_p4k_hjd_5s} {#r_GlideFormRemoveOption_String_String__table_q4k_hjd_5s__entry__2}

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

{#r_GlideFormRemoveOption_String_String__table_q4k_hjd_5s}  

    g_form.removeOption('priority', '1');

## GlideForm - save() {#ariaid-title65}

Saves the record without navigating away (update and stay).
{#r_GlideFormSave__table_xgb_3qd_5s__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 127. Parameters]

{#r_GlideFormSave__table_xgb_3qd_5s} {#r_GlideFormSave__table_ygb_3qd_5s__entry__2}

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

{#r_GlideFormSave__table_ygb_3qd_5s}

## GlideForm - setChoiceLabel(String fieldName, String choiceValue, String newLabel) {#ariaid-title66}

Updates the label of a specific choice in the drop-down field.
When calling this method, the index position of the updated option in the drop-down remains unchanged. The enabled or disabled state of the option is preserved.
{#GF-setChoiceLabel_S_S_S__table_q2s_gds_rfc__entry__3}

| Name | Type | Description |
|-|-|-|
| fieldName | String | Field name that contains the choice to update. Data type: String |
| choiceValue | String | Value of the choice label to update with a new label. Data type: String |
| newLabel | String | Label name to update the existing choice label to. Data type: String |
[Table 129. Parameters]

{#GF-setChoiceLabel_S_S_S__table_q2s_gds_rfc} {#GF-setChoiceLabel_S_S_S__table_fvm_xbs_rfc__entry__2}

| Type | Description |
|-|-|
| Boolean | Flag that indicates whether the option label is updated successfully. Valid values: * true: Choice label is updated. * false: Choice label isn't updated because the specified choice to update may have been read-only or does not exist, or the new label exists and is already associated with another option. {#GF-setChoiceLabel_S_S_S__ul_m4d_pfq_xfc} |
[Table 130. Returns]

{#GF-setChoiceLabel_S_S_S__table_fvm_xbs_rfc}  
The following example calls setChoiceLabel() to update the 'bonus' field choices (10, 20, and 30) to new values.

    // Show the calculated bonus next to the percentage label
    var salary = parseInt(g_form.getValue('salary'), 10); 
    g_form.setChoiceLabel('bonus', '10', '10% ($'+ (salary * .10) +')'); 
    g_form.setChoiceLabel('bonus', '20', '20% ($'+ (salary * .20) +')'); 
    g_form.setChoiceLabel('bonus', '30', '30% ($'+ (salary * .30) +')');

## GlideForm - setDisabled(String fieldName, Boolean disable) {#ariaid-title67}

Makes the specified field available or unavailable.
{#r_GlideFormSetDisabled_String_Boolean__table_sn2_j4c_5s__entry__3}{#r_GlideFormSetDisabled_String_Boolean__g_form-setDisabled-fieldName-entry}{#r_GlideFormSetDisabled_String_Boolean__g_form-setDisabled-disable-entry}

| Name | Type | Description |
|-|-|-|
| fieldName | String | Name of the field to enable or disable. |
| disable | Boolean | Flag that indicates whether to disable the specified field. Valid values: * true: Disable the field. * false: Enables the field. {#r_GlideFormSetDisabled_String_Boolean__ul_odn_3hw_jfc} Default: false |
[Table 131. Parameters]

{#r_GlideFormSetDisabled_String_Boolean__table_sn2_j4c_5s} {#r_GlideFormSetDisabled_String_Boolean__table_tn2_j4c_5s__entry__2}

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

{#r_GlideFormSetDisabled_String_Boolean__table_tn2_j4c_5s}

## GlideForm - setDisplay(String fieldName, Boolean display) {#ariaid-title68}

Displays or hides a specified field on the form.
This method can't hide a mandatory field with no value. If the field is hidden, the space is used to display other items. Whenever possible, use a UI policy instead of this method.
{#r_GlideFormSetDisplay_String_Boolean__table_k4d_ctw_ts__entry__3}{#r_GlideFormSetDisplay_String_Boolean__g_form-setDisplay-fieldName-entry}{#r_GlideFormSetDisplay_String_Boolean__g_form-setDisplay-display-entry}

| Name | Type | Description |
|-|-|-|
| fieldName | String | Name of the field. |
| display | Boolean | Flag that indicates whether to display the specified field. Valid values: * true: Display the field. * false: Hide the field. {#r_GlideFormSetDisplay_String_Boolean__ul_vdd_sqg_5fc} |
[Table 133. Parameters]

{#r_GlideFormSetDisplay_String_Boolean__table_k4d_ctw_ts} {#r_GlideFormSetDisplay_String_Boolean__table_l4d_ctw_ts__entry__2}

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

{#r_GlideFormSetDisplay_String_Boolean__table_l4d_ctw_ts}  

    function onChange(control, oldValue, newValue, isLoading, isTemplate) {
       //If the page isn't loading
       if (!isLoading) {
          //If the new value isn't blank
          if (newValue != '') {
             g_form.setDisplay('priority', false);   
          }
          else 
             g_form.setDisplay('priority', true);
          }
       }

## GlideForm - setLabelOf(String fieldName, String label) {#ariaid-title69}

Sets the plain text value of the specified field label.
Note:  
This method is not supported by Service Catalog.
{#r_GlideFormSetLabelOf_String_String__table_h5q_ytw_ts__entry__3}{#r_GlideFormSetLabelOf_String_String__g_form-setLabelOf-fieldName-entry}{#r_GlideFormSetLabelOf_String_String__g_form-setLabelOf-label-entry}

| Name | Type | Description |
|-|-|-|
| fieldName | String | Name of the field for which to set the label. |
| label | String | Plain text value to set in the label. |
[Table 135. Parameters]

{#r_GlideFormSetLabelOf_String_String__table_h5q_ytw_ts} {#r_GlideFormSetLabelOf_String_String__table_i5q_ytw_ts__entry__2}

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

{#r_GlideFormSetLabelOf_String_String__table_i5q_ytw_ts}  

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

## GlideForm - setMandatory(String fieldName, Boolean mandatory) {#ariaid-title70}

Makes the specified field mandatory.
Mandatory fields are visually distinguished by an asterisk next to the field label. The asterisk is red if the field is empty, and black if the field is not empty. The system displays a
validation message if a user attempts to save or submit the form without completing those fields. For more information, see [Form fields](https://www.servicenow.com/docs/access?context=c_FormFields&version=australia&pubname=australia-platform-user-interface&ft:locale=en-US).  
Note:  
Whenever possible, use a UI policy rather than this method.
{#r_GF-SetMandatory_S_B__table_xnx_z4c_5s__entry__3}{#r_GF-SetMandatory_S_B__g_form-setMandatory-fieldName-entry}{#r_GF-SetMandatory_S_B__g_form-setMandatory-mandatory-entry}

| Name | Type | Description |
|-|-|-|
| fieldName | String | Name of the field to make mandatory. |
| mandatory | Boolean | Flag that indicates whether the field is mandatory. Valid values: * true: Field is mandatory. * false: Field is optional. {#r_GF-SetMandatory_S_B__ul_ofd_sqg_5fc} Default: false |
[Table 137. Parameters]

{#r_GF-SetMandatory_S_B__table_xnx_z4c_5s} {#r_GF-SetMandatory_S_B__table_ynx_z4c_5s__entry__2}

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

{#r_GF-SetMandatory_S_B__table_ynx_z4c_5s}

## GlideForm - setReadOnly(String fieldName, Boolean readOnly) {#ariaid-title71}

Makes the specified field read-only or editable.
Whenever possible, use a UI policy instead of this method.

To make a mandatory field read-only, you must first remove the mandatory requirement for
that field by using the setMandatory() method.

Once you set a field to read-only, you cannot use the [setValue()](https://www.servicenow.com/docs/HNdDSrkfvw56bJr9GUeUlA#r_GlideForm-SetValue_S_S_S "Sets the value of a specified form field to the specified value or the value of a specified display value in a reference record.") method to update the value of that field. If you need to set the value in this way, you must set the readOnly value to `false.`
{#r_GlideFormSetReadOnly_String_Boolean__table_xdf_qpc_5s__entry__3}{#r_GlideFormSetReadOnly_String_Boolean__g_form-setReadOnly-fieldName-entry}{#r_GlideFormSetReadOnly_String_Boolean__g_form-setReadOnly-readOnly-entry}

| Name | Type | Description |
|-|-|-|
| fieldName | String | Name of the field whose access value to set. |
| readOnly | Boolean | Flag that determines whether the associate field is editable or read-only. Valid values: * true: Set field to read-only. * false: Set field to be editable. {#r_GlideFormSetReadOnly_String_Boolean__ul_tfd_sqg_5fc} |
[Table 139. Parameters]

{#r_GlideFormSetReadOnly_String_Boolean__table_xdf_qpc_5s} {#r_GlideFormSetReadOnly_String_Boolean__table_ydf_qpc_5s__entry__2}

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

{#r_GlideFormSetReadOnly_String_Boolean__table_ydf_qpc_5s}  
The following example shows how set the Variable Editor to read only. To do this in Service Catalog tables, use setVariablesReadOnly().

    // Create a Client Script on a table (e.g., incident) and paste this script
    // Uncheck (set to false) the "isolate script" checkbox (not available by default)
    // To add the isolate script checkbox to the form, configure form layout to add the checkbox
    function onLoad() { 
      $("variable_map").querySelectorAll("item").forEach(function(item){
        var variable = item.getAttribute("qname"); 
        g_form.setReadOnly("variables."+ variable, true); 
      }); 
    }

## GlideForm - setRelatedLinksDisplay(Boolean display) {#ariaid-title72}

Show or hide the Related Links section in the form UI using Boolean values.
[GlideForm - hideRelatedLinks()](https://www.servicenow.com/docs/HNdDSrkfvw56bJr9GUeUlA#GF-hideRelatedLinks "Hides the Related Links section of a form.") hides related link UI Actions on the form, while [GlideForm - showRelatedLinks()](https://www.servicenow.com/docs/HNdDSrkfvw56bJr9GUeUlA#GF-showRelatedLinks "Displays the Related Links section of a form.") shows them. The g_form.setRelatedLinksDisplay(boolean: display) method, however, can be used to either show or hide related links with more flexibility in your scripts.
{#GF-setRelatedLinksDisplay_B__table_ebq_t1t_rfc__entry__3}

| Name | Type | Description |
|-|-|-|
| display | Boolean | Flag that indicates whether to show or hide the Related Links section of a form. Valid values: * true: Displays related links in the form. * false: Hides related links in the form. {#GF-setRelatedLinksDisplay_B__ul_bks_tbt_rfc} Default: true |
[Table 141. Parameters]

{#GF-setRelatedLinksDisplay_B__table_ebq_t1t_rfc} {#GF-setRelatedLinksDisplay_B__table_fbq_t1t_rfc__entry__2}

| Type | Description |
|-|-|
| None |   |
[Table 142. Returns]

{#GF-setRelatedLinksDisplay_B__table_fbq_t1t_rfc}  
The following example demonstrates how to show or hide the Related Links section in a form.

    // Displays the Related Links section in the UI
    g_form.setRelatedLinksDisplay(true);
    // Hides the Related Links section in the UI
    g_form.setRelatedLinksDisplay(false);

## GlideForm - setSectionDisplay(String sectionName, Boolean display) {#ariaid-title73}

Shows or hides a specified section in the form.
{#r_GF-SetSectionDisplay_S_B__table_pqq_qqd_5s__entry__3}{#r_GF-SetSectionDisplay_S_B__g_form-setSectionDisplay-sectionName-entry}{#r_GF-SetSectionDisplay_S_B__g_form-setSectionDisplay-display-entry}

| Name | Type | Description |
|-|-|-|
| sectionName | String | Section name is lower case with an underscore replacing the first space in the name, and with the remaining spaces being removed. For example, "Section Four is Here" becomes "section_fourishere". Other non-alphanumeric characters, such as ampersands (\&), are removed. Section names can be found by using the getSectionNames() method. |
| display | Boolean | Flag that indicates whether to show the section. Valid values: * true: Show the section. * false: Hide the section. {#r_GF-SetSectionDisplay_S_B__ul_odd_sqg_5fc} |
[Table 143. Parameters]

{#r_GF-SetSectionDisplay_S_B__table_pqq_qqd_5s} {#r_GF-SetSectionDisplay_S_B__table_qqq_qqd_5s__entry__2}{#r_GF-SetSectionDisplay_S_B__g_form-setSectionDisplay-returns-entry}

| Type | Description |
|-|-|
| Boolean | Returns true when successful. |
[Table 144. Returns]

{#r_GF-SetSectionDisplay_S_B__table_qqq_qqd_5s}

## GlideForm - setValue(String fieldName, String value, String displayValue) {#ariaid-title74}

Sets the value of a specified form field to the specified value or the value of a specified display value in a reference record.
To improve performance by preventing a round trip when setting the value for a reference
field, use this method, not setValue(fieldName, value). When setting
multiple reference values for a list collector field, pass arrays in the
value and displayValue parameters.

This method also supports setting values in a multi-row variable set (MRVS). You must first use `JSON.parse(getValue('<mrvs_field_name>'))` to obtain the MRVS array and then use indexing to update the fields
within the row objects. Once all values are updated in the MRVS, use the setValue() method to save the updated MRVS array. For more details, see the code example below.  
Note:  
This method can't be used to update fields set to strict read only. If this method is called on strict read only fields, the field isn't updated and a warning is logged in the browser console. For more information, see [Configuring read-only security options](https://www.servicenow.com/docs/access?context=read-only-option&version=australia&pubname=australia-platform-administration&ft:locale=en-US).  
Note:  
This method can't be used to update fields set to strict read only. If this method is called on strict read only fields, the field isn't updated and a warning is logged in the browser console. For more information, see [Configuring read-only security options](https://www.servicenow.com/docs/access?context=read-only-option&version=australia&pubname=australia-platform-administration&ft:locale=en-US).  
Note:  
The method setValue() can cause a stack overflow when used in an `onchange` client script. This is because every time the value is set, it will register as a change, which may re-trigger the OnChange client script. To prevent this, perform a check that will validate that the new value will be different from the old value. For example, before performing `setValue(shortDesc, newValue.toUpperCase());`, validate that the short description is not already uppercase. This will prevent the client script from applying the toUpperCase() more than once.
{#r_GlideForm-SetValue_S_S_S__table_oxn_vrc_5s__entry__3}{#r_GlideForm-SetValue_S_S_S__g_form-setValue-fieldName-entry}{#r_GlideForm-SetValue_S_S_S__g_form-setValue-value-entry}{#r_GlideForm-SetValue_S_S_S__g_form-setValue-displayValue-entry}

| Name | Type | Description |
|-|-|-|
| fieldName | String | Name of the form field to update. |
| value | String or Array | Sys_id of the reference record to use to update the field. If the specified field is a GlideList, this parameter can contain an array of sys_ids. In this case, the method performs a lookup of all records specified in the array and those values are used to update the contents of the specified field (related list). Note: When defining a value in a choice list, be sure to use a number value rather than the label. |
| displayValue | String or Array | Optional. Field within the specified reference record to use to update the specified field. For example, in the User \[sys_user\] table it might be userName. If the specified field is a GlideList, this parameter can contain an array of display value names. For additional information on display values, see [Display value](https://www.servicenow.com/docs/access?context=c_DisplayValues&version=australia&pubname=australia-platform-administration&ft:locale=en-US). |
[Table 145. Parameters]

{#r_GlideForm-SetValue_S_S_S__table_oxn_vrc_5s} {#r_GlideForm-SetValue_S_S_S__table_pxn_vrc_5s__entry__2}

| Type | Description |
|-|-|
| None |   |
[Table 146. Returns]

{#r_GlideForm-SetValue_S_S_S__table_pxn_vrc_5s}  
The following example shows how to set the short description in the current form.

    g_form.setValue('short_description', 'replace this with appropriate text');

The following example shows how to set values in an MRVS. In this example, salaries are being managed through the Service Catalog. The client script searches all rows within the MRVS for the value entered in the Job title and then updates the matching entries within the MRVS with what is entered in the Salary field. The MRVS is named "variable_set_1" and contains the following fields within each row
object: Employee name \[employee_name\], Job title \[employee_job_title\], and Salary \[employee_salary\]. In addition, the Catalog Item contains: Job title \[job_title\] and Salary \[salary\].

    function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
    return;
    }

    // Get the MRVS
    var multiRowVariableSet = JSON.parse(g_form.getValue('variable_set_1'));

    for (var i = 0; i < multiRowVariableSet.length; i++) {
    // Check if the entered job title matches the title in the current MRVS row
      if (multiRowVariableSet[i].employee_job_title == g_form.getValue("job_title")){
        // Update the value of a matching field with the new salary
        multiRowVariableSet[i].employee_salary = newValue;
      }
    }

    // Update the MRVS
    g_form.setValue('variable_set_1', JSON.stringify(multiRowVariableSet));
    }

This example shows passing the sys_id of the reference record that contains the userName
field to use to update the assigned_to form field.

    g_form.setValue('assigned_to', userSysID, userName);

This example shows passing an array of reference record sys_ids and an array of
corresponding display value names to use to update the form fields in the GlideList
glide-list_field_name.

    g_form.setValue('glide-list_field_name', sysIDArray, displayNameArray);

## GlideForm - setVariablesReadOnly(Boolean isReadOnly) {#ariaid-title75}

Makes a Service Catalog variable editor read only.
Note:  
This method is only applicable to Service Catalog variable editors in the core UI. This method is not supported in the Service Catalog form.

The method must be placed in the client script of the table in which the variable editor is
added, such as Requested Item \[sc_req_item\], Incident \[incident\], and so on. To set
variables to read only in other tables, use the [setReadOnly()](https://www.servicenow.com/docs/HNdDSrkfvw56bJr9GUeUlA#r_GlideFormSetReadOnly_String_Boolean "Makes the specified field read-only or editable.") method.

See also: [Service Catalog variable
editors](https://www.servicenow.com/docs/access?context=service-catalog-variable-editor&version=australia&pubname=australia-servicenow-platform&ft:locale=en-US)
{#GF-setVariablesReadOnly_B__table_xdf_qpc_5s__entry__3}{#GF-setVariablesReadOnly_B__g_form-setVariablesReadOnly-isReadOnly-entry}

| Name | Type | Description |
|-|-|-|
| isReadOnly | Boolean | Flag that determines whether the variable editor is read only. Valid values: * true: Sets the variable editor as read-only. * false: Sets the variable editor as editable. {#GF-setVariablesReadOnly_B__ul_ifd_sqg_5fc} Default: false |
[Table 147. Parameters]

{#GF-setVariablesReadOnly_B__table_xdf_qpc_5s} {#GF-setVariablesReadOnly_B__table_ydf_qpc_5s__entry__2}

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

{#GF-setVariablesReadOnly_B__table_ydf_qpc_5s}  
Adding the following line to a client script sets the variable editor to read only.

    g_form.setVariablesReadOnly(true);

## GlideForm - setVisible(String fieldName, Boolean display) {#ariaid-title76}

Displays or hides the specified field.
On desktop UI, the space is left blank when hidden. On Mobile or Service Portal UI, the space is filled in my other fields when hidden. This method can't hide mandatory fields with no value.

Use UI Policy rather than this method whenever possible.
{#r_GlideFormSetVisible_String_Boolean__table_k24_45w_ts__entry__3}{#r_GlideFormSetVisible_String_Boolean__g_form-setVisible-fieldName-entry}{#r_GlideFormSetVisible_String_Boolean__g_form-setVisible-display-entry}

| Name | Type | Description |
|-|-|-|
| fieldName | String | Name of the field to display or hide. |
| display | Boolean | Flag that indicates whether to display the specified field. Valid values: * true: Display the field. * false: Hide the field. {#r_GlideFormSetVisible_String_Boolean__ul_c2d_sqg_5fc} |
[Table 149. Parameters]

{#r_GlideFormSetVisible_String_Boolean__table_k24_45w_ts} {#r_GlideFormSetVisible_String_Boolean__table_l24_45w_ts__entry__2}

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

{#r_GlideFormSetVisible_String_Boolean__table_l24_45w_ts}  

    function onChange(control, oldValue, newValue, isLoading, isTemplate) {
       //If the page isn't loading
       if (!isLoading) {
          //If the new value isn't blank
          if(newValue != '') {
             g_form.setVisible('priority', false); 
          }
          else
             g_form.setVisible('priority', true); 
          }
       }

## GlideForm - showAnnotation(String name) {#ariaid-title77}

Shows an annotation with a given name on the form UI.
[Annotations](https://www.servicenow.com/docs/access?context=configure-form-layout&version=australia&pubname=australia-platform-administration&section=t_AddAFormAnnotation&ft:locale=en-US) are visual separators between form elements, or blocks of colored text used to highlight form elements. See also:

* [GlideForm - hideAnnotation(String name)](https://www.servicenow.com/docs/HNdDSrkfvw56bJr9GUeUlA#GF-hideAnnotation_S "Hides an annotation with a given name on the form UI.") to hide a specific annotation on the form.
* [GlideForm - toggleAnnotations()](https://www.servicenow.com/docs/HNdDSrkfvw56bJr9GUeUlA#GF-toggleAnnotations "Hides or shows all annotations on the form.") to toggle annotations on and off with greater flexibility.
{#GF-showAnnotation_S__ul_iqn_jmf_wfc}
{#GF-showAnnotation_S__table_isv_1nt_rfc__entry__3}

| Name | Type | Description |
|-|-|-|
| name | String | Name of the annotation to show in the form. Table: Form Annotations \[sys_ui_annotation\], Field: Name |
[Table 151. Parameters]

{#GF-showAnnotation_S__table_isv_1nt_rfc} {#GF-showAnnotation_S__table_jsv_1nt_rfc__entry__2}

| Type | Description |
|-|-|
| None |   |
[Table 152. Returns]

{#GF-showAnnotation_S__table_jsv_1nt_rfc}  
The following example demonstrates how to programmatically show the annotation named test-annotation-msg on the form field using the showAnnotation() method.

    g_form.showAnnotation('test-annotation-msg');

## GlideForm - showErrorBox(String name, String message, Boolean scrollForm) {#ariaid-title78}

Displays an error message under the specified form field (either a control object or the name of the field). If the control or field is currently off the screen and the scrollForm parameter is true, the form scrolls to the control or field.
A global property (glide.ui.scroll_to_message_field) is available that controls automatic
message scrolling when the form field is off screen (scrolls the form to the control or
field). The showFieldMsg() method is a similar method that requires a
type parameter.
{#r_GF-ShowErrorBox_S_S_B__table_lyr_dww_ts__entry__3}{#r_GF-ShowErrorBox_S_S_B__g_form-showErrorBox-name-entry}{#r_GF-ShowErrorBox_S_S_B__g_form-showErrorBox-message-entry}{#r_GF-ShowErrorBox_S_S_B__g_form-showErrorBox-scrollForm-entry}

| Name | Type | Description |
|-|-|-|
| name | String | Name of the field or control under which to display the error message. |
| message | String | Error message to display. |
| scrollForm | Boolean | Flag that indicates whether to automatically scroll the form to the error message field. Valid values: * true: Scroll to the error message field. * false: Don't scroll to the error message field. {#r_GF-ShowErrorBox_S_S_B__ul_bgd_sqg_5fc} Default: true |
[Table 153. Parameters]

{#r_GF-ShowErrorBox_S_S_B__table_lyr_dww_ts} {#r_GF-ShowErrorBox_S_S_B__table_myr_dww_ts__entry__2}

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

{#r_GF-ShowErrorBox_S_S_B__table_myr_dww_ts}

## GlideForm - showErrorBox(String name, String message) {#ariaid-title79}

Displays an error message under the specified form field (either a control object or the name of the field). If the control or field is currently off the screen, the form automatically scrolls to the control or field.
A global property (glide.ui.scroll_to_message_field) is available that controls automatic
message scrolling when the form field is off screen (scrolls the form to the control or
field). The showFieldMsg() method is a similar method that requires a
type parameter.
{#r_GlideFormShowErrorBox_String_String__table_rxv_2vw_ts__entry__3}{#r_GlideFormShowErrorBox_String_String__g_form-showErrorBox-name-entry}{#r_GlideFormShowErrorBox_String_String__g_form-showErrorBox-message-entry}

| Name | Type | Description |
|-|-|-|
| name | String | Name of the field or control under which to display the error message. |
| message | String | Error message to display. |
[Table 155. Parameters]

{#r_GlideFormShowErrorBox_String_String__table_rxv_2vw_ts} {#r_GlideFormShowErrorBox_String_String__table_sxv_2vw_ts__entry__2}

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

{#r_GlideFormShowErrorBox_String_String__table_sxv_2vw_ts}

## GlideForm - showFieldMsg(String field, String message, String type) {#ariaid-title80}

Displays a message under the specified form field (either a control object or the name of the field). If the control or field is off the screen, the method automatically scrolls the form to that field.
A global property (glide.ui.scroll_to_message_field) is available that controls automatic
message scrolling when the form field is off screen (scrolls the form to the control or
field).

The showErrorBox() method is a shorthand method that does not require
the type parameter.  
Note:  
This method does not work with the journal_field type field in Core UI.
{#r_GF-ShowFieldMsg_S_S_S__table_u3z_hxw_ts__entry__3}{#r_GF-ShowFieldMsg_S_S_S__g_form-showFieldMsg-field-entry}{#r_GF-ShowFieldMsg_S_S_S__g_form-showFieldMsg-message-entry}{#r_GF-ShowFieldMsg_S_S_S__g_form-showFieldMsg-type-entry}

| Name | Type | Description |
|-|-|-|
| field | String | Name of the field or control under which to display the message. |
| message | String | Message to display. |
| type | String | Type of message. Valid values: * error * info * warning {#r_GF-ShowFieldMsg_S_S_S__ul_vgd_sqg_5fc} |
[Table 157. Parameters]

{#r_GF-ShowFieldMsg_S_S_S__table_u3z_hxw_ts} {#r_GF-ShowFieldMsg_S_S_S__table_v3z_hxw_ts__entry__2}

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

{#r_GF-ShowFieldMsg_S_S_S__table_v3z_hxw_ts}  

    g_form.showFieldMsg('impact','Low impact response time can be one week','info');

## GlideForm - showFieldMsg(String field, String message, String type, Boolean
scrollForm) {#ariaid-title81}

Displays a message under the specified form field (either a control object or the name of the field). If the control or field is currently off the screen and scrollForm is `true`, the method scrolls the form to that field.
A global property (glide.ui.scroll_to_message_field) is available that controls automatic
message scrolling when the form field is off screen (scrolls the form to the control or
field).

The showErrorBox() method is a shorthand method that does not require
the type parameter.  
Note:  
This method does not work with the journal_field type field in Core UI.
{#r_GF-ShowFieldMsg_S_S_S_B__table_wmr_gyw_ts__entry__3}{#r_GF-ShowFieldMsg_S_S_S_B__g_form-showFieldMsg-field-entry}{#r_GF-ShowFieldMsg_S_S_S_B__g_form-showFieldMsg-message-entry}{#r_GF-ShowFieldMsg_S_S_S_B__g_form-showFieldMsg-type-entry}{#r_GF-ShowFieldMsg_S_S_S_B__g_form-showFieldMsg-scrollForm-entry}

| Name | Type | Description |
|-|-|-|
| field | String | Name of the field or control under which to display the message. |
| message | String | Message to display. |
| type | String | Type of message. Valid values: * error * info * warning {#r_GF-ShowFieldMsg_S_S_S_B__ul_vgd_sqg_5fc} |
| scrollForm | Boolean | Flag that indicates whether to automatically scroll the form to the message field. Valid values: * true: Scroll to the message field. * false: Don't scroll to the message field. {#r_GF-ShowFieldMsg_S_S_S_B__ul_hgd_sqg_5fc} Default: true |
[Table 159. Parameters]

{#r_GF-ShowFieldMsg_S_S_S_B__table_wmr_gyw_ts} {#r_GF-ShowFieldMsg_S_S_S_B__table_xmr_gyw_ts__entry__2}

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

{#r_GF-ShowFieldMsg_S_S_S_B__table_xmr_gyw_ts}  

    g_form.showFieldMsg('impact','Low impact not allowed with High priority','error',false);

## GlideForm - showRelatedLinks() {#ariaid-title82}

Displays the Related Links section of a form.
See also:

* [GlideForm - hideRelatedLinks()](https://www.servicenow.com/docs/HNdDSrkfvw56bJr9GUeUlA#GF-hideRelatedLinks "Hides the Related Links section of a form.")
* [GlideForm - setRelatedLinksDisplay(Boolean display)](https://www.servicenow.com/docs/HNdDSrkfvw56bJr9GUeUlA#GF-setRelatedLinksDisplay_B "Show or hide the Related Links section in the form UI using Boolean values.")
{#GF-showRelatedLinks__ul_lbh_5hq_vfc}
{#GF-showRelatedLinks__table_wgv_31t_rfc__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 161. Parameters]

{#GF-showRelatedLinks__table_wgv_31t_rfc} {#GF-showRelatedLinks__table_xgv_31t_rfc__entry__2}

| Type | Description |
|-|-|
| None |   |
[Table 162. Returns]

{#GF-showRelatedLinks__table_xgv_31t_rfc}  
The following example displays related links in the form UI.

    // Show related links
    g_form.showRelatedLinks()

## GlideForm - showRelatedList(String listTableName) {#ariaid-title83}

Displays the specified related list on the form.
This method isn't available on the mobile platform. If this method is run on a mobile platform, no action occurs.
{#r_GlideFormShowRelatedList_String__table_mps_2zw_ts__entry__3}{#r_GlideFormShowRelatedList_String__g_form-showRelatedList-listTableName-entry}

| Name | Type | Description |
|-|-|-|
| listTableName | String | Name of the related list to display. |
[Table 163. Parameters]

{#r_GlideFormShowRelatedList_String__table_mps_2zw_ts} {#r_GlideFormShowRelatedList_String__table_nps_2zw_ts__entry__2}

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

{#r_GlideFormShowRelatedList_String__table_nps_2zw_ts}

## GlideForm - showRelatedLists() {#ariaid-title84}

Displays all the form's related lists.
This method isn't available on the mobile platform. If this method is run on a mobile platform, no action occurs.
{#r_GlideFormShowRelatedLists__table_jcj_rzw_ts__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 165. Parameters]

{#r_GlideFormShowRelatedLists__table_jcj_rzw_ts} {#r_GlideFormShowRelatedLists__table_kcj_rzw_ts__entry__2}

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

{#r_GlideFormShowRelatedLists__table_kcj_rzw_ts}

## GlideForm - showTemplateBar() {#ariaid-title85}

If hidden, shows the template bar at the bottom of the form.
{#GF-showTemplateBar__table_ivb_s5g_5fc__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 167. Parameters]

{#GF-showTemplateBar__table_ivb_s5g_5fc} {#GF-showTemplateBar__table_jvb_s5g_5fc__entry__2}

| Type | Description |
|-|-|
| None |   |
[Table 168. Returns]

{#GF-showTemplateBar__table_jvb_s5g_5fc}  
The following example script displays the Template Bar at the bottom of the current form.

    g_form.showTemplateBar()

## GlideForm - submit() {#ariaid-title86}

Saves the record.
The user is taken away from the form, returning them to where they were.
{#r_GlideFormSubmit__table_nhk_grd_5s__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 169. Parameters]

{#r_GlideFormSubmit__table_nhk_grd_5s} {#r_GlideFormSubmit__table_ohk_grd_5s__entry__2}

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

{#r_GlideFormSubmit__table_ohk_grd_5s}

## GlideForm - submit(String verb) {#ariaid-title87}

Performs the specified UI action.
{#GF-submit_S__table_o1z_d3p_qx__entry__3}{#GF-submit_S__g_form-submit-verb-entry}

| Name | Type | Description |
|-|-|-|
| verb | String | An action_name from a sys_ui_action record. The action name must be for a visible form button. |
[Table 171. Parameters]

{#GF-submit_S__table_o1z_d3p_qx} {#GF-submit_S__table_p1z_d3p_qx__entry__2}

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

{#GF-submit_S__table_p1z_d3p_qx}

## GlideForm - toggleAnnotations() {#ariaid-title88}

Hides or shows all annotations on the form.
[Annotations](https://www.servicenow.com/docs/access?context=configure-form-layout&version=australia&pubname=australia-platform-administration&section=t_AddAFormAnnotation&ft:locale=en-US) are visual separators between form elements, or blocks of colored text used to highlight form elements. If annotations are visible on the form, calling
toggleAnnotations() hides them. Similarly if annotations are hidden on the form, calling this method displays them.  
See also:

* [GlideForm - hideAnnotation(String name)](https://www.servicenow.com/docs/HNdDSrkfvw56bJr9GUeUlA#GF-hideAnnotation_S "Hides an annotation with a given name on the form UI.")
* [GlideForm - showAnnotation(String name)](https://www.servicenow.com/docs/HNdDSrkfvw56bJr9GUeUlA#GF-showAnnotation_S "Shows an annotation with a given name on the form UI.")
{#GF-toggleAnnotations__ul_ytp_ytm_5fc}
{#GF-toggleAnnotations__table_xqy_vjz_rfc__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 173. Parameters]

{#GF-toggleAnnotations__table_xqy_vjz_rfc} {#GF-toggleAnnotations__table_yqy_vjz_rfc__entry__2}

| Type | Description |
|-|-|
| None |   |
[Table 174. Returns]

{#GF-toggleAnnotations__table_yqy_vjz_rfc}  
The following example shows how to call toggleAnnotations() to show or hide form annotations. As a result, annotations are hidden or shown depending on their previous state.

    g_form.toggleAnnotations();


