{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":159,"path":"api-reference/GlideFormAPINX.md","title":"GlideForm \\(Next Experience\\) - Client","bundle":null,"doc_type":null,"release":"australia","body":"\n# GlideForm \\(Next Experience\\) - Client\n\nThe GlideForm API provides methods to customize forms in the Next Experience UI Framework.\n\nOnly 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.\n\nYou 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.\n\n**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://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/scripts/r_MobilePlatformMigrationImpacts.md).\n\nThere is no constructor for the GlideForm class. Access GlideForm methods using the `g_form` global object.\n\n**Parent Topic:**[Client Next Experience API reference](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/api-client-next.md)\n\n## GlideForm \\(Next Experience\\) - addAdditionalParams\\(String parameterName, String value\\)\n\nAdds a hidden input with given name and value parameter to the form.\n\n|Name|Type|Description|\n|----|----|-----------|\n|parameterName|String|Name of the parameter to add.|\n|value|String|Value of the parameter to add.|\n\n|Type|Description|\n|----|-----------|\n|None| |\n\nThe following example customizes the behavior of the **Update** button on the **Incident** form so that users are redirected back to the list view in the default view, but remain on the record in the **Advanced View** after saving.\n\n```\n\n// Create an onLoad client script for the incident table with the following script.\n\nfunction onLoad() {\n   g_form.addAdditionalParam('view_name', g_form.getViewName());\n}\n```\n\nEdit the global `sysverb_update` UI action and add the following script.\n\n```\ncurrent.update();\nif (RP.getParameterValue(\"view_name\") == \"advanced\") {\n  // Keep the record open if saving from the advanced view\n  action.openGlideRecord(current);\n\n// To test:\n// Open the incident list and edit an incident. Click Update to be redirected to the list.\n// Open /incident_list.do?sysparm_view=advanced and edit an incident. Click Update to be redirected back to the edited incident.\n```\n\n## GlideForm \\(Next Experience\\) - addChoice\\(String fieldName, String choiceValue, String choiceLabel\\)\n\nAdds a choice to the end of a specified choice list field.\n\n|Name|Type|Description|\n|----|----|-----------|\n|fieldName|String|Name of the field in which to add the choice field option.|\n|choiceValue|String|Value to store in the database.|\n|choiceLabel|String|Value to display.|\n\n|Type|Description|\n|----|-----------|\n|None| |\n\n```\ng_form.addChoice('priority', '6', '6 - Really Low');\n```\n\n## GlideForm \\(Next Experience\\) - addDecoration\\(String fieldName, String icon, String title\\)\n\nAdds an icon on a field's label.\n\nAdding the same item twice is prevented; however, you can add the same icon with a different title.\n\n**Note:** This method is not supported by Service Catalog.\n\n<table id=\"table_vyw_1dw_ts\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nfieldName\n\n</td><td>\n\nString\n\n</td><td id=\"g_form-add_decor-fieldName-entry\">\n\nField name.\n\n</td></tr><tr><td>\n\nicon\n\n</td><td>\n\nString\n\n</td><td id=\"g_form-add_decor-icon-entry\">\n\nName of the icon to show next to the specified field.Valid values:\n\n-   icon-add\n-   icon-alert\n-   icon-book\n-   icon-book-open\n-   icon-calendar\n-   icon-cards\n-   icon-cart-full\n-   icon-catalog\n-   icon-check-circle\n-   icon-cog\n-   icon-comment\n-   icon-console\n-   icon-dashboard\n-   icon-database\n-   icon-delete\n-   icon-drawer\n-   icon-edit\n-   icon-filter\n-   icon-folder\n-   icon-form\n-   icon-help\n-   icon-home\n-   icon-image\n-   icon-info\n-   icon-label\n-   icon-lightbulb\n-   icon-list\n-   icon-livefeed\n-   icon-locked\n-   icon-mail\n-   icon-mobile\n-   icon-new-ticket\n-   icon-paperclip\n-   icon-power\n-   icon-script\n-   icon-search\n-   icon-sort-ascending\n-   icon-star\n-   icon-star-empty\n-   icon-tab\n-   icon-trash\n-   icon-tree\n-   icon-tree-right\n-   icon-user\n-   icon-user-group\n-   icon-view\n\n</td></tr><tr><td>\n\ntitle\n\n</td><td>\n\nString\n\n</td><td id=\"g_form-add_decor-title-entry\">\n\nTitle for the icon.\n\n</td></tr></tbody>\n</table>|Type|Description|\n|----|-----------|\n|None| |\n\n```\ng_form.addDecoration('caller_id', 'icon-star', 'preferred member');\n```\n\n## GlideForm \\(Next Experience\\) - addDecoration\\(String fieldName, String icon, String title, String color\\)\n\nAdds an icon on a field's label.\n\nAdding the same item twice is prevented; however, you can add the same icon with a different title.\n\n**Note:** This method is not supported by Service Catalog.\n\n<table id=\"table_gzh_fyd_5s\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nfieldName\n\n</td><td>\n\nString\n\n</td><td id=\"g_form-add_decor-fieldName-entry\">\n\nField name.\n\n</td></tr><tr><td>\n\nicon\n\n</td><td>\n\nString\n\n</td><td id=\"g_form-add_decor-icon-entry\">\n\nName of the icon to show next to the specified field.Valid values:\n\n-   icon-add\n-   icon-alert\n-   icon-book\n-   icon-book-open\n-   icon-calendar\n-   icon-cards\n-   icon-cart-full\n-   icon-catalog\n-   icon-check-circle\n-   icon-cog\n-   icon-comment\n-   icon-console\n-   icon-dashboard\n-   icon-database\n-   icon-delete\n-   icon-drawer\n-   icon-edit\n-   icon-filter\n-   icon-folder\n-   icon-form\n-   icon-help\n-   icon-home\n-   icon-image\n-   icon-info\n-   icon-label\n-   icon-lightbulb\n-   icon-list\n-   icon-livefeed\n-   icon-locked\n-   icon-mail\n-   icon-mobile\n-   icon-new-ticket\n-   icon-paperclip\n-   icon-power\n-   icon-script\n-   icon-search\n-   icon-sort-ascending\n-   icon-star\n-   icon-star-empty\n-   icon-tab\n-   icon-trash\n-   icon-tree\n-   icon-tree-right\n-   icon-user\n-   icon-user-group\n-   icon-view\n\n</td></tr><tr><td>\n\ntitle\n\n</td><td>\n\nString\n\n</td><td id=\"g_form-add_decor-title-entry\">\n\nTitle for the icon.\n\n</td></tr><tr><td>\n\ncolor\n\n</td><td>\n\nString\n\n</td><td id=\"g_form-add_decor-color-entry\">\n\nCSS color.\n\n</td></tr></tbody>\n</table>|Type|Description|\n|----|-----------|\n|None| |\n\n```\ng_form.addDecoration('caller_id', 'icon-star', 'Mark as Favorite', 'color-green');\n```\n\n## GlideForm \\(Next Experience\\) - addErrorMessage\\(String message\\)\n\nDisplays the specified error message at the top of the form.\n\nThis message appears for approximately four seconds and then disappears. This timeout is not configurable at this time.\n\n|Name|Type|Description|\n|----|----|-----------|\n|message|String|Message to display.|\n\n|Type|Description|\n|----|-----------|\n|None| |\n\n```\ng_form.addErrorMessage('This is an error');\n```\n\n## GlideForm \\(Next Experience\\) - addFormMessage\\(String message, String type, Object options\\)\n\nDisplays a floating form message at the top of the form detail section. The message doesn't cover UI actions.\n\nSee also:\n\n-   [clearAllFormMessages\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/GlideFormAPINX.md)\n-   [clearFormMessages\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/GlideFormAPINX.md)\n\n<table id=\"table_f2v_zym_4pb\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nmessage\n\n</td><td>\n\nString\n\n</td><td id=\"g_form-add_form_msg-message-entry\">\n\nMessage to display.\n\n</td></tr><tr><td>\n\ntype\n\n</td><td>\n\nString\n\n</td><td id=\"glideform-parm-type-entry\">\n\nType of message.Valid values:\n\n-   error\n-   info\n-   warning\n\n</td></tr><tr><td>\n\noptions\n\n</td><td>\n\nObject\n\n</td><td id=\"g_form-add_form_msg-options-entry\">\n\nOptional. Buttons to add to the form message and any metadata needed to handle a button click.```\n{\n  buttons: [Array],\n  meta: {Object}\n}\n```\n\n</td></tr><tr><td>\n\noptions.buttons\n\n</td><td>\n\nArray\n\n</td><td id=\"g_form-add_form_msg-options_buttons-entry\">\n\nList of buttons to add to the form message.```\nbuttons: [\n  {\n    actionName: \"String\",\n    label: \"String\"\n  }\n]\n```\n\n</td></tr><tr><td>\n\noptions.buttons.actionName\n\n</td><td>\n\nString\n\n</td><td id=\"g_form-add_form_msg-options_buttons_actionName-entry\">\n\nName 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`.\n\n</td></tr><tr><td>\n\noptions.buttons.label\n\n</td><td>\n\nString\n\n</td><td id=\"g_form-add_form_msg-options_buttons_label-entry\">\n\nText to display on the button.\n\n</td></tr><tr><td>\n\noptions.meta\n\n</td><td>\n\nObject\n\n</td><td id=\"g_form-add_form_msg-options_meta-entry\">\n\nMap of any metadata needed to handle the button click formatted as key-value pairs. ```\nmeta: {\n  'key': 'value'\n}\n```\n\nFor example, for an **Assign to me** button the event handler needs the sys\\_id of the user to assign the record to.\n\n</td></tr></tbody>\n</table>|Type|Description|\n|----|-----------|\n|None| |\n\nThe following example shows how to add form messages of each type.\n\n```\ng_form.addFormMessage('info message','info');\ng_form.addFormMessage('warning message','warning');\ng_form.addFormMessage('error message','error');\ng_form.addFormMessage('info2 message','info');\ng_form.addFormMessage('warning2 message','warning');\ng_form.addFormMessage('error2 message','error');\ng_form.addFormMessage('Would you like to reassign this to yourself?', 'info', {buttons: [{label: \"Assign to me\", actionName: \"assign_to_me\"}], meta: {'userId': '46d44a23a9fe19810012d100cca80666'}});\n```\n\n## GlideForm \\(Next Experience\\) - addInfoMessage\\(String message\\)\n\nAdds the specified informational message to the top of the form.\n\nThis message appears for approximately four seconds and then disappears. This timeout is not configurable at this time.\n\n|Name|Type|Description|\n|----|----|-----------|\n|message|String|Message to display.|\n\n|Type|Description|\n|----|-----------|\n|None| |\n\n```\ng_form.addInfoMessage('The top five fields in this form are mandatory');\n```\n\n## GlideForm \\(Next Experience\\) - addHighMessage\\(String message\\)\n\nDisplays a high priority message at the top of the form.\n\nThis message appears for approximately four seconds and then disappears. This timeout is not configurable at this time.\n\n|Name|Type|Description|\n|----|----|-----------|\n|message|String|Message to display on the form.|\n\n|Type|Description|\n|----|-----------|\n|None| |\n\nThe following example shows how to display a high priority message at the top of the form.\n\n```\ng_form.addHighMessage(“This is a high priority message\");\n```\n\n## GlideForm \\(Next Experience\\) - addLowMessage\\(String message\\)\n\nDisplays a low priority message at the top of the form.\n\nThis message appears for approximately four seconds and then disappears. This timeout is not configurable at this time.\n\n|Name|Type|Description|\n|----|----|-----------|\n|message|String|Message to display on the form.|\n\n|Type|Description|\n|----|-----------|\n|None| |\n\nThe following example shows how to display a low priority message at the top of the form.\n\n```\ng_form.addLowMessage(“This is a low priority message \"); \n```\n\n## GlideForm \\(Next Experience\\) - addModerateMessage\\(String message\\)\n\nDisplays a moderate priority message at the top of the form.\n\nThis message appears for approximately four seconds and then disappears. This timeout is not configurable at this time.\n\n|Name|Type|Description|\n|----|----|-----------|\n|message|String|Message to display on the form.|\n\n|Type|Description|\n|----|-----------|\n|None| |\n\nThe following example shows how to display a moderate priority message at the top of the form.\n\n```\ng_form.addModerateMessage(“This is a moderate priority message\");\n```\n\n## GlideForm \\(Next Experience\\) - addOption\\(String fieldName, String choiceValue, String choiceLabel\\)\n\nAdds a choice to the end of a specified choice list field.\n\n|Name|Type|Description|\n|----|----|-----------|\n|fieldName|String|Name of the field in which to add the choice field option.|\n|choiceValue|String|Value to store in the database.|\n|choiceLabel|String|Value to display.|\n\n|Type|Description|\n|----|-----------|\n|None| |\n\n```\ng_form.addOption('priority', '6', '6 - Really Low');\n```\n\n## GlideForm \\(Next Experience\\) - addOption\\(String fieldName, String choiceValue, String choiceLabel, Number choiceIndex\\)\n\nAdds a choice to the list field at the position specified.\n\n**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.\n\n|Name|Type|Description|\n|----|----|-----------|\n|fieldName|String|Name of the field in which to add the choice field option.|\n|choiceValue|String|Value to store in the database.|\n|choiceLabel|String|Value to display.|\n|choiceIndex|Number|Order of the choice in the list. The index is a zero-based array.|\n\n|Type|Description|\n|----|-----------|\n|None| |\n\n```\ng_form.addOption('priority', '2.5', '2.5 - Moderately High', 3);\n```\n\n## GlideForm \\(Next Experience\\) - addSuccessMessage\\(String message\\)\n\nDisplays a message confirming a successful action at the top of the form.\n\nThis message appears for approximately four seconds and then disappears. This timeout is not configurable at this time.\n\n|Name|Type|Description|\n|----|----|-----------|\n|message|String|Success message to display.|\n\n|Type|Description|\n|----|-----------|\n|None| |\n\nThe following example shows how to display a message confirming a success message at the top of the form.\n\n```\ng_form.addSuccessMessage(“This is a success message\");\n```\n\n## GlideForm \\(Next Experience\\) - clearAllFormMessages\\(\\)\n\nRemoves all form messages of any type.\n\nSee also:\n\n-   [GlideForm \\(Next Experience\\) - addFormMessage\\(String message, String type, Object options\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/GlideFormAPINX.md)\n-   [GlideForm \\(Next Experience\\) - clearMessages\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/GlideFormAPINX.md)\n-   [clearFormMessages\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/GlideFormAPINX.md)\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|None| |\n\nThe following example shows how to clear all messages from the form.\n\n```\ng_form.clearAllFormMessages();\n```\n\n## GlideForm \\(Next Experience\\) - clearChoices\\(String fieldName\\)\n\nRemoves all choices in a specified choice list field.\n\n| | | |\n|---|---|---|\n|fieldName|String|Name of the field for which to clear the full list of choices.|\n\n|Type|Description|\n|----|-----------|\n|None| |\n\n```\ng_form.clearChoices('priority');\n```\n\n## GlideForm \\(Next Experience\\) - clearFormMessages\\(String type\\)\n\nRemoves all form messages of a specified type.\n\nSee also:\n\n-   [GlideForm \\(Next Experience\\) - addFormMessage\\(String message, String type, Object options\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/GlideFormAPINX.md)\n-   [GlideForm \\(Next Experience\\) - clearMessages\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/GlideFormAPINX.md)\n-   [GlideForm \\(Next Experience\\) - clearAllFormMessages\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/GlideFormAPINX.md)\n\n<table id=\"table_ilw_bzm_4pb\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\ntype\n\n</td><td>\n\nString\n\n</td><td id=\"glideform-parm-type-entry\">\n\nType of message.Valid values:\n\n-   error\n-   info\n-   warning\n\n</td></tr></tbody>\n</table>|Type|Description|\n|----|-----------|\n|None| |\n\nThe following example shows how to clear all error messages from the form.\n\n```\ng_form.clearFormMessages('error');\n```\n\n## GlideForm \\(Next Experience\\) - clearMessages\\(\\)\n\nRemoves all informational and error messages from the top of the form.\n\nRemoves informational and error messages added with g\\_form.addInfoMessage\\(\\) and g\\_form.addErrorMessage\\(\\).\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|None| |\n\n```\ng_form.clearMessages();\n```\n\n## GlideForm \\(Next Experience\\) - clearOptions\\(String fieldName\\)\n\nRemoves all options from the specified choice list.\n\n|Name|Type|Description|\n|----|----|-----------|\n|fieldName|String|Name of the field for which to clear the choice options.|\n\n|Type|Description|\n|----|-----------|\n|None| |\n\n```\ng_form.clearOptions('priority');\n```\n\n## GlideForm \\(Next Experience\\) - clearValue\\(String fieldName\\)\n\nRemoves any value\\(s\\) from the specified field.\n\n**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://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/platform-administration/read-only-option.md).\n\n|Name|Type|Description|\n|----|----|-----------|\n|fieldName|String|Name of the field to clear.|\n\n|Type|Description|\n|----|-----------|\n|None| |\n\n## GlideForm \\(Next Experience\\) - disableAttachments\\(\\)\n\nPrevents file attachments from being added to the form.\n\nThis method is not available on the mobile platform. If this method is run on a mobile platform, no action occurs.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|None| |\n\n## GlideForm \\(Next Experience\\) - disableChoice\\(String fieldName, String choiceValue\\)\n\nProgrammatically turns off a specific choice in the drop-down field, if the choice exists. No changes are made if the choice is already turned off.\n\n<table id=\"table_q2s_gds_rfc\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nfieldName\n\n</td><td>\n\nString\n\n</td><td>\n\nField name of the choice to turn off.Data type: String\n\n</td></tr><tr><td>\n\nchoiceValue\n\n</td><td>\n\nString\n\n</td><td>\n\nValue of the choice to turn off.Data type: String\n\n</td></tr></tbody>\n</table><table id=\"table_fvm_xbs_rfc\" class=\"returns\"><thead><tr><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nBoolean\n\n</td><td>\n\nFlag that indicates whether the given choice is turned off or active in the form.Valid values:\n\n-   true: Choice is turned off.\n-   false: Option is already turned off or is not found.\n\nData type: Boolean\n\n</td></tr></tbody>\n</table>The following example calls disableChoice\\(\\) to turn off the loading\\_dock choice in the delivery\\_location form field.\n\n```\nif (g_form.getValue('address_type') == 'home') {\n\tg_form.disableChoice('delivery_location', 'loading_dock');\n}\n\n// Only itil_admin users can select the \"Closed\" option  \n\nfunction onLoad() {\n\tif (g_user.hasRole('itil_admin')) return;\n\n\tif (g_form.getValue('incident_state') != '7')\n\t\tg_form.disableChoice('incident_state', 7);\n\n\tif (g_form.getValue('state') != '7') {\n\t\tg_form.disableChoice('state', 7);\n\t}\n\n}\n```\n\n## GlideForm \\(Next Experience\\) - enableAttachments\\(\\)\n\nAllows file attachments to be added to the form. Shows the paper clip icon.\n\nThis method is not available on the mobile platform. If this method is run on a mobile platform, no action occurs.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|None| |\n\n## GlideForm \\(Next Experience\\) - enableChoice\\(String fieldName, String choiceValue\\)\n\nProgrammatically enables a specific choice in the drop-down field, if the choice exists. No changes are made if the option is already enabled.\n\n|Name|Type|Description|\n|----|----|-----------|\n|fieldName|String|Field name of the choice to enable.|\n|choiceValue|String|Value of the choice to enable.|\n\n<table id=\"table_fvm_xbs_rfc\" class=\"returns\"><thead><tr><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nBoolean\n\n</td><td>\n\nFlag that indicates whether the given choice is successfully enabled.Valid values:\n\n-   true: Choice is enabled.\n-   false: Choice is already enabled or is not found.\n\nData type: Boolean\n\n</td></tr></tbody>\n</table>The following example calls enable\\(\\) to enable a new drop-down choice, `1`, in the `priority` form field.\n\n```\nvar shortDescription = g_form.getValue('shortDescription');\n\n// Allow priority 1 selection if short description mentions security \nif (shortDescription.includes('security')) {\n\tvar p1Choice = g_form.getChoice('priority', '1');\n\tg_form.enableChoice('priority', '1');\n}\n```\n\n## GlideForm \\(Next Experience\\) - flash\\(String fieldName, String color, Number count\\)\n\nUse to draw attention to a field. Flashes the specified color for a specified duration of time in the specified field.\n\nThis method is not supported by Service Catalog.\n\nThis method is not available on the mobile platform. If this method is run on a mobile platform, no action occurs.\n\n<table id=\"table_htn_w2w_ts\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nfieldName\n\n</td><td>\n\nString\n\n</td><td id=\"g_form-flash-fieldName-entry\">\n\nField to highlight in the following format: `\"<table-name>.<field-name>\"`.\n\n</td></tr><tr><td>\n\ncolor\n\n</td><td>\n\nString\n\n</td><td id=\"g_form-flash-color-entry\">\n\nRGB color or acceptable CSS color.\n\n</td></tr><tr><td>\n\ncount\n\n</td><td>\n\nNumber\n\n</td><td id=\"g_form-flash-count-entry\">\n\nHow long the label will flash. Valid values:\n\n-   2: Flashes for 1 second\n-   0: Flashes for 2 seconds\n-   -2: Flashes for 3 seconds\n-   -4: Flashes for 4 seconds\n\n</td></tr></tbody>\n</table>|Type|Description|\n|----|-----------|\n|None| |\n\n```\ng_form.flash(\"incident.number\", \"#FFFACD\", 0);\n```\n\n## GlideForm \\(Next Experience\\) - getActionName\\(\\)\n\nReturns the most recent action name, or, for a client script, the sys\\_id of the UI action clicked.\n\n**Note:** Not available in Wizard client scripts.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|String|Current action name or sys\\_id of the UI action clicked.|\n\n```\nfunction onSubmit() {\n   var action = g_form.getActionName();\n   alert('You pressed ' + action);\n}\n```\n\n## GlideForm \\(Next Experience\\) - getAnnotations\\(\\)\n\nReturns a list of all annotations on a form.\n\n[Annotations](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/platform-administration/configure-form-layout.md) are visual separators between form elements, or blocks of colored text used to highlight form elements. Use [GlideForm \\(Next Experience\\) - getAnnotationByName\\(String name\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/GlideFormAPINX.md) to return a specific annotation by its name.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n<table id=\"table_irm_qnl_rfc\" class=\"returns\"><thead><tr><th>\n\nProperty\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nArray of Objects\n\n</td><td>\n\nContent of the annotation.Data type: Array of Objects\n\n```\n[{content: \"String\", name: \"String\", visible: Boolean}]\n```\n\n</td></tr><tr><td>\n\narray.content\n\n</td><td>\n\nText of the returned annotation.Data type: String\n\n</td></tr><tr><td>\n\narray.name\n\n</td><td>\n\nName of the returned annotation.Data type: String\n\nTable location: Form Annotations \\[sys\\_ui\\_annotation\\], Field: **name**\n\n</td></tr><tr><td>\n\narray.visible\n\n</td><td>\n\nFlag that indicates whether the annotation is visible on the form.\n\n Valid values:\n\n-   true: The annotation is visible.\n-   false: The annotation isn't visible.\n\n Data type: Boolean\n\n</td></tr></tbody>\n</table>The following example first calls getAnnotations\\(\\) to return all annotations in a form, and then calls hideAnnotation\\(\\) to hide all annotations in the form.\n\n```\nconst annotations = getAnnotations();\n\n/* returns:  \n[ \n    { \n        \"name\": \"test-annotation-msg-1\", \n        \"visible\": true, \n        \"content\": \"Test<input id=\\\"make_spacing_ok\\\" style=\\\"visibility:hidden; width:0px;\\\">\" \n    }, \n    { \n        \"name\": \"test-annotation-msg-2\", \n        \"visible\": true, \n        \"content\": \"Test 2<input id=\\\"make_spacing_ok\\\" style=\\\"visibility:hidden; width:0px;\\\">\" \n    } \n\n]*/\nannotations.forEach(function(annotation) {\n\tg_form.hideAnnotation(annotation.name);\n});\n\n// this script hides all annotations on the form. \n```\n\n## GlideForm \\(Next Experience\\) - getAnnotationByName\\(String name\\)\n\nReturns a form annotation of a given name.\n\n[Annotations](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/platform-administration/configure-form-layout.md) are visual separators between form elements, or blocks of colored text used to highlight form elements. Use [GlideForm \\(Next Experience\\) - getAnnotations\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/GlideFormAPINX.md) to return all annotations in a form.\n\n<table id=\"table_skr_c4l_rfc\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nname\n\n</td><td>\n\nString\n\n</td><td>\n\nThe name of the annotation to return.Table: Form Annotations \\[sys\\_ui\\_annotation\\], Field: **Name**\n\n</td></tr></tbody>\n</table><table id=\"table_irm_qnl_rfc\" class=\"returns\"><thead><tr><th>\n\nProperty\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nArray of Objects\n\n</td><td>\n\nContent of the annotation.Data type: Array of Objects\n\n```\n[{content: \"String\", name: \"String\", visible: Boolean}]\n```\n\n</td></tr><tr><td>\n\narray.content\n\n</td><td>\n\nText of the returned annotation.Data type: String\n\n</td></tr><tr><td>\n\narray.name\n\n</td><td>\n\nName of the returned annotation.Data type: String\n\nTable location: Form Annotations \\[sys\\_ui\\_annotation\\], Field: **name**\n\n</td></tr><tr><td>\n\narray.visible\n\n</td><td>\n\nFlag that indicates whether the annotation is visible on the form.\n\n Valid values:\n\n-   true: The annotation is visible.\n-   false: The annotation isn't visible.\n\n Data type: Boolean\n\n</td></tr></tbody>\n</table>The following example demonstrates how to use the getAnnotationByName\\(\\) method to retrieve a form annotation according to its given name, test-annotation-msg-1.\n\n```\n   var sampleAnnotation = g_form.getAnnotationByName(\"test-annotation-msg-1\");\n\n   /* returns:  \n   { \n       \"name\": \"test-annotation-msg-1\", \n       \"visible\": true, \n       \"content\": \"Test<input id=\\\"make_spacing_ok\\\" style=\\\"visibility:hidden; width:0px;\\\">\" \n   }\n   */\n```\n\n## GlideForm \\(Next Experience\\) - getBooleanValue\\(String fieldName\\)\n\nReturns a Boolean value for the specified field.\n\n|Name|Type|Description|\n|----|----|-----------|\n|fieldName|String|Field to highlight in the following format: `\"<table-name>.<field-name>\"`.|\n\n|Type|Description|\n|----|-----------|\n|Boolean|Returns false if the field value is false or undefined; otherwise returns true.|\n\n## GlideForm \\(Next Experience\\) - getChoice\\(String fieldName, String choiceValue\\)\n\nReturns an object with properties representing a given field and choice value.\n\n|Name|Type|Description|\n|----|----|-----------|\n|fieldName|String|Field name of the choice to retrieve.|\n|choiceValue|String|Value of the choice to retrieve.|\n\n<table id=\"table_fvm_xbs_rfc\" class=\"returns\"><thead><tr><th>\n\nProperty\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nGlideFormChoice object or null\n\n</td><td>\n\nGlideFormChoice object for the specified field and choice value. Returns null if no matching choice exists.Data type: Object\n\n```\n(\"label\", \"value\", \"disabled\", \"index\")\n```\n\n</td></tr><tr><td>\n\nGlideFormChoice.label\n\n</td><td>\n\nRead-only display text of the choice.Data type: String\n\n</td></tr><tr><td>\n\nGlideFormChoice.value\n\n</td><td>\n\nRead-only value of the choice.Data type: String\n\n</td></tr><tr><td>\n\nGlideFormChoice.disabled\n\n</td><td>\n\nFlag that indicates whether the choice is turned off in the form.Valid values:\n\n-   true: Choice is turned off.\n-   false: Choice is enabled.\n\nData type: Boolean\n\n</td></tr><tr><td>\n\nGlideFormChoice.index\n\n</td><td>\n\nIndicates the position of the choice in the drop-down.Data type: Number\n\n</td></tr></tbody>\n</table>The following example demonstrates how to call g\\_form.getChoice\\(\\) to return information about the `priority` field choices.\n\n```\nvar priority = g_form.getValue('priority'); \n\nvar priorityLabel = g_form.getChoice('priority', priority).label;\n```\n\n## GlideForm \\(Next Experience\\) - getControl\\(String fieldName\\)\n\nReturns the HTML element for the specified field.\n\nCompound 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.\n\nIf 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>`.\n\nThis method is not available in mobile scripts or Service Portal scripts.\n\n|Name|Type|Description|\n|----|----|-----------|\n|fieldName|String|Name of the field for which to return the HTML element.|\n\n|Type|Description|\n|----|-----------|\n|HTMLElement|Field's HTML element.|\n\n## GlideForm \\(Next Experience\\) - getDecimalValue\\(String fieldName\\)\n\nReturns the decimal value of the specified field.\n\n|Name|Type|Description|\n|----|----|-----------|\n|fieldName|String|Name of the field for which to return the decimal value.|\n\n|Type|Description|\n|----|-----------|\n|String|Decimal value of the specified field.|\n\n```\nfunction onChange(control, oldValue, newValue, isLoading) {\n   alert(g_form.getDecimalValue('percent_complete'));\n}\n```\n\n## GlideForm \\(Next Experience\\) - getDisplayValue\\(String fieldName\\)\n\nReturns the display value from a form in Service Portal.\n\nSee also:\n\n-   [getValue\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/GlideFormAPINX.md)\n-   [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)\n\n**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.\n\n|Name|Type|Description|\n|----|----|-----------|\n|fieldName|String|Name of the field from which you want to retrieve a value in the form.|\n\n|Type|Description|\n|----|-----------|\n|String|Display value of the specified field.|\n\nThe 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.\n\n```\nfunction onChange(control, oldValue, newValue, isLoading) {\n     if (isLoading || newValue == '') {\n          return;\n     }\n     if(window == null){\n          var valuePortal = g_form.getDisplayValue('requester');\n          alert('Portal->' + valuePortal);\n     }\n     else{\n          var valueNative = g_form.getDisplayBox('requester').value;     \n          alert('CoreUI->' + valueCoreUI);\n     }\n     //Type appropriate comment here, and begin script below\n}\n```\n\n## GlideForm \\(Next Experience\\) - getElement\\(String id\\)\n\nReturns the HTML element specified by the parameter.\n\nCompound 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.\n\nThis method is not available in mobile scripts or Service Portal scripts.\n\n|Name|Type|Description|\n|----|----|-----------|\n|id|String|Field ID.|\n\n|Type|Description|\n|----|-----------|\n|HTMLElement|Field's HTML element.|\n\n## GlideForm \\(Next Experience\\) - getFormElement\\(\\)\n\nReturns the HTML element for the form.\n\nThis method is not available in mobile scripts or Service Portal scripts.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|HTMLFormElement|HTML element for the form.|\n\n## GlideForm \\(Next Experience\\) - getIntValue\\(String fieldName\\)\n\nReturns the integer value for the specified field.\n\n|Name|Type|Description|\n|----|----|-----------|\n|fieldName|String|Field name.|\n\n|Type|Description|\n|----|-----------|\n|Number|Integer value of the field.|\n\n## GlideForm \\(Next Experience\\) - getLabelOf\\(String fieldName\\)\n\nReturns the plain text value of the field label.\n\n|Name|Type|Description|\n|----|----|-----------|\n|fieldName|String|Field name.|\n\n|Type|Description|\n|----|-----------|\n|String|Label text.|\n\n```\nif (g_user.hasRole('itil')) {\n    var oldLabel = g_form.getLabelOf('comments');\n    g_form.setLabelOf('comments', oldLabel + ' (Customer visible)');\n}\n```\n\n## GlideForm \\(Next Experience\\) - getOptions\\(String fieldName\\)\n\nReturns 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.\n\nFor example, you can use the g\\_form.getOptions\\(\\) to:\n\n-   Get and set the name-value pairs in a watch\\_list field type.\n-   Search or filter available options by a search term.\n-   Enable access to the same auto-complete results via a callback.\n-   Get and set options on choice fields, reference fields, and advanced field types such as watch\\_list, glide\\_list, field\\_list, and slushbucket.\n\n|Name|Type|Description|\n|----|----|-----------|\n|fieldName|String|The field name of the choice or reference field to retrieve.|\n\n<table id=\"table_ez3_jyr_rfc\" class=\"returns\"><thead><tr><th>\n\nProperty\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nArray of Objects or null\n\n</td><td>\n\nRead-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\n\n```\n[{value: \"String\", displayValue: \"String\"}]\n```\n\n</td></tr><tr><td>\n\narray.displayValue\n\n</td><td>\n\nThe choice display value.Data type: String\n\n</td></tr><tr><td>\n\narray.value\n\n</td><td>\n\nThe value of the option.Data type: String\n\n</td></tr><tr><td>\n\ngetAvailable\\(term\\)\n\n</td><td>\n\nFunction 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\n\n```\n[{value: \"String\", displayValue: \"String\"}]\n```\n\n</td></tr></tbody>\n</table>The following example calls g\\_form.getOptions\\(\\) to return all available choices for specified form fields, like state, work\\_notes\\_list, and others.\n\n```\ng_form.getOptions(\"state\"); //table: incident, field: state, type: integer, choice: Dropdown without --None--\n/*\nreturns [{\"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\"}]\n*/\n\ng_form.getOptions(\"category\"); //table: incident, field: category, type: string, choice: Dropdown with --None--\n/*\nreturns [{\"value\":\"\",\"displayValue\":\"-- None --\"},{\"value\":\"inquiry\",\"displayValue\":\"Inquiry / Help\"},{\"value\":\"software\",\"displayValue\":\"Software\"},{\"value\":\"hardware\",\"displayValue\":\"Hardware\"},{\"value\":\"network\",\"displayValue\":\"Network\"},{\"value\":\"database\",\"displayValue\":\"Database\"}]\n*/\n\ng_form.getOptions(\"work_notes_list\") //table: incident, field: work_notes_list, type: glide_list\n/*\nreturns [{\"value\":\"62826bf03710200044e0bfc8bcbe5df1\",\"displayValue\":\"Abel Tuter\"},{\"value\":\"a8f98bb0eb32010045e1a5115206fe3a\",\"displayValue\":\"Abraham Lincoln\"},{\"value\":\"5137153cc611227c000bbd1bd8cd2005\",\"displayValue\":\"Fred Luddy\"},{\"value\":\"6a826bf03710200044e0bfc8bcbe5dec\",\"displayValue\":\"Alissa Mountjoy\"}]\n*/\n\ng_form.getOptions(\"restricted_fields\") //table: std_change_properties, field: restricted_fields, type: field_list\n/*\n[{\"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\"},...]\n*/\n\ng_form.getOptions('table') //table: sys_script_client, field: table, type: table_name\n/*\n[{\"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]\"},...]\n*/\n\ng_form.getOptions('mandatory_fields'); //table: kb_knowledge_base, field: mandatory_fields, type: slushbucket\n/*\n[{\"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\"},...]\n*/\n```\n\nThe following example script demonstrates how to call g\\_form.getOptions\\(\\) with getAvailable\\(\\) function.\n\n```\nconst options = g_form.getOptions('priority');\nif (options) {\n  console.log('Selected:', options.selected);\n  options.getAvailable('high').then(available => {\n    console.log('Available matching \"high\":', available);\n  });\n}\n```\n\n## GlideForm \\(Next Experience\\) - getReference\\(String fieldName, Function callBack\\)\n\nReturns the GlideRecord for a specified field.\n\nIf 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.\n\n**Important:** It is strongly recommended that you use a callback function.\n\nCallback function support for ServiceCatalogForm.getReference is available.\n\n**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://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/scripts/client-script-best-practices.md).\n\n|Name|Type|Description|\n|----|----|-----------|\n|fieldName|String|Name of the field.|\n|callBack|Function|Name of the call back function.|\n\n<table id=\"table_l4c_1yb_5s\" class=\"returns\"><thead><tr><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nGlideRecord\n\n</td><td id=\"g_form-getReference-returns-entry\">\n\nGlideRecord 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`.\n\n</td></tr></tbody>\n</table>```\nfunction onChange(control, oldValue, newValue, isLoading) {\n    g_form.getReference('caller_id', doAlert); // doAlert is our callback function\n}\n \nfunction doAlert(caller) { // reference is passed into callback as first arguments\n   if (caller.getValue('vip') == 'true') {\n      alert('Caller is a VIP!');\n   }\n}\n```\n\n## GlideForm \\(Next Experience\\) - getRelatedListNames\\(\\)\n\nReturns an array of related list names from the current form.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|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.|\n\n```\nvar listNames = g_form.getRelatedListNames();\n\nfor (var i = 0; i < listNames.length; i++) {  \n  this.showRelatedList(listNames[i]);\n }\n```\n\n## GlideForm \\(Next Experience\\) - getSectionNames\\(\\)\n\nReturns all section names, whether visible or not.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|Array of Strings|Section names.|\n\n## GlideForm \\(Next Experience\\) - getSections\\(\\)\n\nReturns an array of the form's sections.\n\nThis method is not available on the mobile platform. If this method is run on a mobile platform, no action occurs.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|Array of HTML elements|Form's sections.|\n\n```\nfunction onChange(control, oldValue, newValue, isLoading) {\n   //this example was run on a form divided into sections (Change form)\n   // and hid a section when the \"state\" field was changed\n   var sections = g_form.getSections();\n   if (newValue == '2') {\n      g_form.setSectionDisplay(sections[1], false);\n   } else {\n      g_form.setSectionDisplay(sections[1], true);\n   }\n}\n```\n\n## GlideForm \\(Next Experience\\) - getTableName\\(\\)\n\nReturns the name of the table to which this record belongs.\n\nOn the server side, the table for the current record can be retrieved with current.sys\\_class\\_name or current.getTableName\\(\\).\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|String|Name of the table.|\n\n```\nfunction onLoad() {\n    if (g_form.isNewRecord()) {\n        var tableName = g_form.getTableName(); //Get the table name\n    }\n}\n```\n\n## GlideForm \\(Next Experience\\) - getUniqueValue\\(\\)\n\nReturns the sys\\_id of the record displayed in the form.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|String|Record's sys\\_id.|\n\n```\nfunction onLoad() {\n   var incSysid = g_form.getUniqueValue();\n   alert(incSysid);\n}\n```\n\n## GlideForm \\(Next Experience\\) - getValue\\(String fieldName\\)\n\nReturns the value of the specified form field.\n\nThis 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.\n\n|Name|Type|Description|\n|----|----|-----------|\n|fieldName|String|Name of the field whose value to return.|\n\n|Type|Description|\n|----|-----------|\n|String|Value of the specified field.|\n\nThe following example shows how to get the short description from the current form.\n\n```\nfunction onChange(control, oldValue, newValue, isLoading) {\n   alert(g_form.getValue('short_description'));\n}\n```\n\nThe 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\\].\n\n```\nfunction onChange(control, oldValue, newValue, isLoading) {\nif (isLoading || newValue == '') {\nreturn;\n}\n \n// Get the MRVS\nvar vs1 = g_form.getValue('variable_set_1') || '[]';\nvar multiRowVariableSet = JSON.parse(vs1);\n \nfor (var i = 0; i < multiRowVariableSet.length; i++) {\n// Check if the entered job title matches the title in the current MRVS row\n  if (multiRowVariableSet[i].employee_job_title == g_form.getValue(\"job_title\")){\n    // Update the value of a matching field with the new salary\n    multiRowVariableSet[i].employee_salary = newValue;\n  }\n}\n \n// Update the MRVS\ng_form.setValue('variable_set_1', JSON.stringify(multiRowVariableSet));\n}\n```\n\n## GlideForm \\(Next Experience\\) - hideAllFieldMsgs\\(\\)\n\nHides all field messages.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|None| |\n\n## GlideForm \\(Next Experience\\) - hideAllFieldMsgs\\(String type\\)\n\nHides all field messages of the specified type.\n\n<table id=\"table_y2c_qhw_ts\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\ntype\n\n</td><td>\n\nString\n\n</td><td id=\"g_form-hideAllFieldMsgs_S-type-entry\">\n\n&gt;Type of message.Valid values:\n\n-   error\n-   info\n\n</td></tr></tbody>\n</table>|Type|Description|\n|----|-----------|\n|None| |\n\n## GlideForm \\(Next Experience\\) - hideAnnotation\\(String name\\)\n\nHides an annotation with a given name on the form UI.\n\n[Annotations](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/platform-administration/configure-form-layout.md) are visual separators between form elements, or blocks of colored text used to highlight form elements. See also:\n\n-   [GlideForm \\(Next Experience\\) - showAnnotation\\(String name\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/GlideFormAPINX.md) to display a specific annotation on the form.\n-   [GlideForm \\(Next Experience\\) - toggleAnnotations\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/GlideFormAPINX.md) to toggle annotations on and off with greater flexibility.\n\n<table id=\"table_isv_1nt_rfc\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nname\n\n</td><td>\n\nString\n\n</td><td>\n\nName of the annotation to hide in the form.Table: Form Annotations \\[sys\\_ui\\_annotation\\], Field: **Name**\n\n</td></tr></tbody>\n</table>|Type|Description|\n|----|-----------|\n|None| |\n\nThe following example demonstrates how to programmatically hide the annotation named test-annotation-msg-1 on the form field using the hideAnnotation\\(\\) method.\n\n```\ng_form.hideAnnotation('test-annotation-msg-1');\n```\n\n## GlideForm \\(Next Experience\\) - hideErrorBox\\(String fieldName\\)\n\nHides the error message placed by showErrorBox\\(\\).\n\nWhenever possible, use hideFieldMsg\\(\\) rather than this method whenever possible.\n\n|Name|Type|Description|\n|----|----|-----------|\n|fieldName|String|Name of the field or control whose error message to hide.|\n\n|Type|Description|\n|----|-----------|\n|None| |\n\n## GlideForm \\(Next Experience\\) - hideFieldMsg\\(String fieldName, Boolean clearAll\\)\n\nHides the first message that appears in the specified field on the current form.\n\nUse the [showFieldMsg\\(String field, String message, String type\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/GlideFormAPINX.md) or [showFieldMsg\\(String field, String message, String type, Boolean scrollForm\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/GlideFormAPINX.md) methods to display messages on a form.\n\nFor 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:\n\n```\ng_form.showFieldMsg('work_notes', 'First message', \"error\");\ng_form.showFieldMsg('work_notes', 'Second message', \"error\");\ng_form.hideFieldMsg('work_notes', false); // This call hides the 'First message'\n```\n\n<table id=\"table_xnf_3pw_ts\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nfieldName\n\n</td><td>\n\nString\n\n</td><td id=\"g_form-hideFieldMsg-fieldName-entry\">\n\nName of the field on which to hide the message.\n\n</td></tr><tr><td>\n\nclearAll\n\n</td><td>\n\nBoolean\n\n</td><td id=\"g_form-hideFieldMsg-clearAll-entry\">\n\nOptional. Flag that indicates whether to hide all messages for the specified field.Valid values:\n\n-   true: Hide all messages.\n-   false: Only hide the first message being displayed.\n\nDefault: false\n\n</td></tr></tbody>\n</table>|Type|Description|\n|----|-----------|\n|None| |\n\nThe following example shows how to clear all messages for a specified form field and then display an encryption error message.\n\n```\nfunction submitEncryptedInputs() {\n  return processEncryptedInputs(function(inputName, fieldName) {\n    if (!checkEncryptedFieldValue(fieldName)) {\n      g_form.hideFieldMsg(fieldName, true); // Hide all messages for the specified field\n      g_form.showFieldMsg(fieldName, \"Your activity requires an encrypted input.\", \"error\");\n      return false;\n    }\n    return true;\n  });\n}\n```\n\n## GlideForm \\(Next Experience\\) - hideRelatedList\\(String listTableName\\)\n\nHides the specified related list on the form.\n\nThis method is not available on the mobile platform. If this method is run on a mobile platform, no action occurs.\n\n|Name|Type|Description|\n|----|----|-----------|\n|listTableName|String|Name of the related list. Use the sys\\_id to hide a list through a relationship.|\n\n|Type|Description|\n|----|-----------|\n|None| |\n\n## GlideForm \\(Next Experience\\) - hideRelatedLists\\(\\)\n\nHides all related lists on the form.\n\nThis method is not available on the mobile platform. If this method is run on a mobile platform, no action occurs.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|None| |\n\n## GlideForm \\(Next Experience\\) - isMandatory\\(String fieldName\\)\n\nReturns true if the field is mandatory.\n\nMandatory 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://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/platform-user-interface/c_FormFields.md).\n\n|Name|Type|Description|\n|----|----|-----------|\n|fieldName|String|Name of the field.|\n\n|Type|Description|\n|----|-----------|\n|Boolean|True if the field is required, false otherwise.|\n\n## GlideForm \\(Next Experience\\) - isNewRecord\\(\\)\n\nReturns true if the record has never been saved.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|Boolean|Returns true if the record has not been saved; otherwise false.|\n\n```\nfunction onLoad() {\n   if(g_form.isNewRecord()){\n      alert('New Record!');\n   }\n}\n```\n\n## GlideForm \\(Next Experience\\) - isVisible\\(String fieldName\\)\n\nDetermines whether the field associated with the passed-in field name is visible on the current form.\n\n|Name|Type|Description|\n|----|----|-----------|\n|fieldName|String|Name of the field to check whether it is visible on the current form.|\n\n<table id=\"table_qs3_gqy_m2c\" class=\"returns\"><thead><tr><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nBoolean\n\n</td><td id=\"g_form-isVisible-returns-entry\">\n\nFlag that indicates whether the specified field is visible on the current form.Possible values:\n\n-   true: Field is visible on the form.\n-   false: Field isn't visible on the form.\n\n</td></tr></tbody>\n</table>The following code example shows how to check if the `user_address` field is visible on the current form.\n\n```\nif(g_form.isVisible('user_address')) {\n    alert('is visible');\n}\nelse {\n    alert('is hidden');\n}\n```\n\n## GlideForm \\(Next Experience\\) - onUserChangeValue\\(Function fn\\)\n\nRegisters a custom event listener that detects when any field in the current form is modified by a user.\n\nWhen 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.\n\n**Note:** This method does not work for journal fields or Service Catalog items in the classic environment.\n\n<table id=\"table_m5y_wll_1hb\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nfn\n\n</td><td>\n\nFunction\n\n</td><td id=\"g_form-onUserChangeValue-fn-entry\">\n\nFunction 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:\n\n-   field name\n-   original field value\n-   updated field value\n\n</td></tr></tbody>\n</table>|Type|Description|\n|----|-----------|\n|Function|Function to call to unregister the onUserChangeValue event listener.|\n\n```\nvar handler = function(fieldname, originalValue, newValue) {\n  console.log('The field ('+ fieldname + ') has a new value of: ' + newValue); // function code\n}\n \nvar unregister = g_form.onUserChangeValue(handler);\n \n// To unregister the event listener\nunregister();\n```\n\n## GlideForm \\(Next Experience\\) - removeChoice\\(String fieldName, String choiceValue\\)\n\nRemoves the specified choice from the specified choice list field.\n\n| | | |\n|---|---|---|\n|fieldName|String|Name of the filed from which to remove a single choice from the choice list.|\n|choiceValue|String|Value of the choice to remove from the choice list.|\n\n|Type|Description|\n|----|-----------|\n|None| |\n\n```\ng_form.removeChoice('priority', '1');\n```\n\n## GlideForm \\(Next Experience\\) - removeDecoration\\(String fieldname, String icon, String title\\)\n\nRemoves the icon from the specified field that matches the specified icon and title.\n\n**Note:** This method isn't supported by Service Catalog.\n\n|Name|Type|Description|\n|----|----|-----------|\n|fieldName|String|Field name from which to remove the decoration.|\n|icon|String|Name of the icon to remove.|\n|title|String|Icon's text title \\(name\\).|\n\n|Type|Description|\n|----|-----------|\n|None| |\n\n```\nfunction onChange(control, oldValue, newValue, isLoading) {\n\t// if the caller_id field is not present, then we can't add an icon anywhere\n\tif (!g_form.hasField('caller_id'))\n\t\treturn;\n \n\tif (!newValue)\n\t\treturn;\n \n\tg_form.getReference('caller_id', function(ref) {\n\t\tg_form.removeDecoration('caller_id', 'icon-star', 'VIP');\n \n\t\tif (ref.getValue('vip') == 'true')\n\t\t\tg_form.addDecoration('caller_id', 'icon-star', 'VIP');\t\t\t\n\t});\n}\n```\n\n## GlideForm \\(Next Experience\\) - removeDecoration\\(String fieldname, String icon, String title, String color\\)\n\nRemoves the icon from the specified field that matches the specified icon, title, and color.\n\n**Note:** This method isn't supported by Service Catalog.\n\n|Name|Type|Description|\n|----|----|-----------|\n|fieldName|String|Field name from which to remove the decoration.|\n|icon|String|Name of the icon to remove.|\n|title|String|Icon's text title \\(name\\).|\n|color|String|CSS color to match.|\n\n|Type|Description|\n|----|-----------|\n|None| |\n\n```\ng_form.removeDecoration('caller_id', 'icon-star', 'VIP', 'blue');\n```\n\n## GlideForm \\(Next Experience\\) - removeOption\\(String fieldName, String choiceValue\\)\n\nRemoves the specified option from the specified choice list.\n\n|Name|Type|Description|\n|----|----|-----------|\n|fieldName|String|Name of the field from which to remove the option from the choice list.|\n|choiceValue|String|Value stored in the database. This is not the label.|\n\n|Type|Description|\n|----|-----------|\n|None| |\n\n```\ng_form.removeOption('priority', '1');\n```\n\n## GlideForm \\(Next Experience\\) - save\\(\\)\n\nSaves the record without navigating away \\(update and stay\\).\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|None| |\n\n## GlideForm \\(Next Experience\\) - setChoiceLabel\\(String fieldName, String choiceValue, String newLabel\\)\n\nUpdates the label of a specific choice in the drop-down field.\n\nWhen calling this method, the index position of the updated option in the drop-down remains unchanged. The enabled or turned off state of the option is preserved.\n\n<table id=\"table_q2s_gds_rfc\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nfieldName\n\n</td><td>\n\nString\n\n</td><td>\n\nField name that contains the choice to update.Data type: String\n\n</td></tr><tr><td>\n\nchoiceValue\n\n</td><td>\n\nString\n\n</td><td>\n\nValue of the choice label to update with a new label.Data type: String\n\n</td></tr><tr><td>\n\nnewLabel\n\n</td><td>\n\nString\n\n</td><td>\n\nLabel name to update the existing choice label to.Data type: String\n\n</td></tr></tbody>\n</table><table id=\"table_fvm_xbs_rfc\" class=\"returns\"><thead><tr><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nBoolean\n\n</td><td>\n\nFlag that indicates whether the option label is updated successfully.Valid values:\n\n-   true: Choice label is updated.\n-   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.\n\n</td></tr></tbody>\n</table>The following example calls setChoiceLabel\\(\\) to update the 'bonus' field choices \\(10, 20, and 30\\) to new values.\n\n```\n// Show the calculated bonus next to the percentage label\nvar salary = parseInt(g_form.getValue('salary'), 10); \ng_form.setChoiceLabel('bonus', '10', '10% ($'+ (salary * .10) +')'); \ng_form.setChoiceLabel('bonus', '20', '20% ($'+ (salary * .20) +')'); \ng_form.setChoiceLabel('bonus', '30', '30% ($'+ (salary * .30) +')');\n```\n\n## GlideForm \\(Next Experience\\) - setDisabled\\(String fieldName, Boolean disable\\)\n\nMakes the specified field available or unavailable.\n\n<table id=\"table_sn2_j4c_5s\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nfieldName\n\n</td><td>\n\nString\n\n</td><td id=\"g_form-setDisabled-fieldName-entry\">\n\nName of the field to enable or turn off.\n\n</td></tr><tr><td>\n\ndisable\n\n</td><td>\n\nBoolean\n\n</td><td id=\"g_form-setDisabled-disable-entry\">\n\nFlag that indicates whether to turn off the specified field.Valid values:\n\n-   true: Turns off the field.\n-   false: Enables the field.\n\nDefault: false\n\n</td></tr></tbody>\n</table>|Type|Description|\n|----|-----------|\n|None| |\n\n## GlideForm \\(Next Experience\\) - setDisplay\\(String fieldName, Boolean display\\)\n\nDisplays or hides a specified field on the form.\n\nThis 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.\n\n<table id=\"table_k4d_ctw_ts\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nfieldName\n\n</td><td>\n\nString\n\n</td><td id=\"g_form-setDisplay-fieldName-entry\">\n\nName of the field.\n\n</td></tr><tr><td>\n\ndisplay\n\n</td><td>\n\nBoolean\n\n</td><td id=\"g_form-setDisplay-display-entry\">\n\nFlag that indicates whether to display the specified field.Valid values:\n\n-   true: Display the field.\n-   false: Hide the field.\n\n</td></tr></tbody>\n</table>|Type|Description|\n|----|-----------|\n|None| |\n\n```\nfunction onChange(control, oldValue, newValue, isLoading, isTemplate) {\n   //If the page isn't loading\n   if (!isLoading) {\n      //If the new value isn't blank\n      if (newValue != '') {\n         g_form.setDisplay('priority', false);   \n      }\n      else \n         g_form.setDisplay('priority', true);\n      }\n   }\n```\n\n## GlideForm \\(Next Experience\\) - setLabelOf\\(String fieldName, String label\\)\n\nSets the plain text value of the specified field label.\n\n**Note:** This method isn't supported by Service Catalog.\n\n|Name|Type|Description|\n|----|----|-----------|\n|fieldName|String|Name of the field for which to set the label.|\n|label|String|Plain text value to set in the label.|\n\n|Type|Description|\n|----|-----------|\n|None| |\n\n```\nif (g_user.hasRole('itil')) {\n    var oldLabel = g_form.getLabelOf('comments');\n    g_form.setLabelOf('comments', oldLabel + ' (Customer visible)');\n}\n```\n\n## GlideForm \\(Next Experience\\) - setMandatory\\(String fieldName, Boolean mandatory\\)\n\nMakes the specified field mandatory.\n\nMandatory 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://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/platform-user-interface/c_FormFields.md).\n\n**Note:** Whenever possible, use a UI policy rather than this method.\n\n<table id=\"table_xnx_z4c_5s\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nfieldName\n\n</td><td>\n\nString\n\n</td><td id=\"g_form-setMandatory-fieldName-entry\">\n\nName of the field to make mandatory.\n\n</td></tr><tr><td>\n\nmandatory\n\n</td><td>\n\nBoolean\n\n</td><td id=\"g_form-setMandatory-mandatory-entry\">\n\nFlag that indicates whether the field is mandatory.Valid values:\n\n-   true: Field is mandatory.\n-   false: Field is optional.\n\nDefault: false\n\n</td></tr></tbody>\n</table>|Type|Description|\n|----|-----------|\n|None| |\n\n## GlideForm \\(Next Experience\\) - setReadOnly\\(String fieldName, Boolean readOnly\\)\n\nMakes the specified field read-only or editable.\n\nWhenever possible, use a UI policy instead of this method.\n\nTo make a mandatory field read-only, you must first remove the mandatory requirement for that field by using the setMandatory\\(\\) method.\n\nOnce you set a field to read-only, you cannot use the [setValue\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/GlideFormAPINX.md) 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.`\n\n<table id=\"table_xdf_qpc_5s\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nfieldName\n\n</td><td>\n\nString\n\n</td><td id=\"g_form-setReadOnly-fieldName-entry\">\n\nName of the field whose access value to set.\n\n</td></tr><tr><td>\n\nreadOnly\n\n</td><td>\n\nBoolean\n\n</td><td id=\"g_form-setReadOnly-readOnly-entry\">\n\nFlag that determines whether the associate field is editable or read-only.Valid values:\n\n-   true: Set field to read-only.\n-   false: Set field to be editable.\n\n</td></tr></tbody>\n</table>|Type|Description|\n|----|-----------|\n|None| |\n\nThe following example shows how set the Variable Editor to read only. To do this in Service Catalog tables, use setVariablesReadOnly\\(\\).\n\n```\n// Create a Client Script on a table (e.g., incident) and paste this script\n// Uncheck (set to false) the \"isolate script\" checkbox (not available by default)\n// To add the isolate script checkbox to the form, configure form layout to add the checkbox\nfunction onLoad() { \n  $(\"variable_map\").querySelectorAll(\"item\").forEach(function(item){\n    var variable = item.getAttribute(\"qname\"); \n    g_form.setReadOnly(\"variables.\"+ variable, true); \n  }); \n}\n```\n\n## GlideForm \\(Next Experience\\) - setSectionDisplay\\(String sectionName, Boolean display\\)\n\nShows or hides a specified section in the form.\n\n<table id=\"table_pqq_qqd_5s\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nsectionName\n\n</td><td>\n\nString\n\n</td><td id=\"g_form-setSectionDisplay-sectionName-entry\">\n\nSection 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 \\(&amp;\\), are removed. Section names can be found by using the getSectionNames\\(\\) method.\n\n</td></tr><tr><td>\n\ndisplay\n\n</td><td>\n\nBoolean\n\n</td><td id=\"g_form-setSectionDisplay-display-entry\">\n\nFlag that indicates whether to show the section.Valid values:\n\n-   true: Show the section.\n-   false: Hide the section.\n\n</td></tr></tbody>\n</table>|Type|Description|\n|----|-----------|\n|Boolean|Returns true when successful.|\n\n## GlideForm \\(Next Experience\\) - setValue\\(String fieldName, String value, String displayValue\\)\n\nSets the value of a specified form field to the specified value or the value of a specified display value in a reference record.\n\nTo 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.\n\nThis 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.\n\n**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://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/platform-administration/read-only-option.md).\n\n**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.\n\n<table id=\"table_oxn_vrc_5s\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nfieldName\n\n</td><td>\n\nString\n\n</td><td id=\"g_form-setValue-fieldName-entry\">\n\nName of the form field to update.\n\n</td></tr><tr><td>\n\nvalue\n\n</td><td>\n\nString or Array\n\n</td><td id=\"g_form-setValue-value-entry\">\n\nSys\\_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\\).\n\n**Note:** When defining a value in a choice list, be sure to use a number value rather than the label.\n\n</td></tr><tr><td>\n\ndisplayValue\n\n</td><td>\n\nString or Array\n\n</td><td id=\"g_form-setValue-displayValue-entry\">\n\nOptional. 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.\n\nFor additional information on display values, see [Display value](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/platform-administration/c_DisplayValues.md).\n\n</td></tr></tbody>\n</table>|Type|Description|\n|----|-----------|\n|None| |\n\nThe following example shows how to set the short description in the current form.\n\n```\ng_form.setValue('short_description', 'replace this with appropriate text');\n```\n\nThe 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\\].\n\n```\nfunction onChange(control, oldValue, newValue, isLoading) {\nif (isLoading || newValue == '') {\nreturn;\n}\n\n// Get the MRVS\nvar multiRowVariableSet = JSON.parse(g_form.getValue('variable_set_1'));\n\nfor (var i = 0; i < multiRowVariableSet.length; i++) {\n// Check if the entered job title matches the title in the current MRVS row\n  if (multiRowVariableSet[i].employee_job_title == g_form.getValue(\"job_title\")){\n    // Update the value of a matching field with the new salary\n    multiRowVariableSet[i].employee_salary = newValue;\n  }\n}\n\n// Update the MRVS\ng_form.setValue('variable_set_1', JSON.stringify(multiRowVariableSet));\n}\n```\n\nThis example shows passing the sys\\_id of the reference record that contains the userName field to use to update the **assigned\\_to** form field.\n\n```\ng_form.setValue('assigned_to', userSysID, userName);\n```\n\nThis 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**.\n\n```\ng_form.setValue('glide-list_field_name', sysIDArray, displayNameArray);\n```\n\n## GlideForm \\(Next Experience\\) - setVariablesReadOnly\\(Boolean isReadOnly\\)\n\nMakes a Service Catalog variable editor read only.\n\n**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.\n\nThe 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://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/GlideFormAPINX.md) method.\n\nSee also: [Service Catalog variable editors](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/servicenow-platform/service-catalog-variable-editor.md)\n\n<table id=\"table_xdf_qpc_5s\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nisReadOnly\n\n</td><td>\n\nBoolean\n\n</td><td id=\"g_form-setVariablesReadOnly-isReadOnly-entry\">\n\nFlag that determines whether the variable editor is read only.Valid values:\n\n-   true: Sets the variable editor as read-only.\n-   false: Sets the variable editor as editable.\n\nDefault: false\n\n</td></tr></tbody>\n</table>|Type|Description|\n|----|-----------|\n|None| |\n\nAdding the following line to a client script sets the variable editor to read only.\n\n```\ng_form.setVariablesReadOnly(true);\n```\n\n## GlideForm \\(Next Experience\\) - setVisible\\(String fieldName, Boolean display\\)\n\nDisplays or hides the specified field.\n\nOn 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.\n\nUse UI Policy rather than this method whenever possible.\n\n<table id=\"table_k24_45w_ts\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nfieldName\n\n</td><td>\n\nString\n\n</td><td id=\"g_form-setVisible-fieldName-entry\">\n\nName of the field to display or hide.\n\n</td></tr><tr><td>\n\ndisplay\n\n</td><td>\n\nBoolean\n\n</td><td id=\"g_form-setVisible-display-entry\">\n\nFlag that indicates whether to display the specified field.Valid values:\n\n-   true: Display the field.\n-   false: Hide the field.\n\n</td></tr></tbody>\n</table>|Type|Description|\n|----|-----------|\n|None| |\n\n```\nfunction onChange(control, oldValue, newValue, isLoading, isTemplate) {\n   //If the page isn't loading\n   if (!isLoading) {\n      //If the new value isn't blank\n      if(newValue != '') {\n         g_form.setVisible('priority', false); \n      }\n      else\n         g_form.setVisible('priority', true); \n      }\n   }\n```\n\n## GlideForm \\(Next Experience\\) - showAnnotation\\(String name\\)\n\nShows an annotation with a given name on the form UI.\n\n[Annotations](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/platform-administration/configure-form-layout.md) are visual separators between form elements, or blocks of colored text used to highlight form elements. See also:\n\n-   [GlideForm \\(Next Experience\\) - hideAnnotation\\(String name\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/GlideFormAPINX.md) to hide a specific annotation on the form.\n-   [GlideForm \\(Next Experience\\) - toggleAnnotations\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/GlideFormAPINX.md) to toggle annotations on and off with greater flexibility.\n\n<table id=\"table_isv_1nt_rfc\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nname\n\n</td><td>\n\nString\n\n</td><td>\n\nName of the annotation to show in the form.Table: Form Annotations \\[sys\\_ui\\_annotation\\], Field: **Name**\n\n</td></tr></tbody>\n</table>|Type|Description|\n|----|-----------|\n|None| |\n\nThe following example demonstrates how to programmatically show the annotation named test-annotation-msg on the form field using the showAnnotation\\(\\) method.\n\n```\ng_form.showAnnotation('test-annotation-msg');\n```\n\n## GlideForm \\(Next Experience\\) - showErrorBox\\(String name, String message\\)\n\nDisplays 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.\n\nA 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.\n\n|Name|Type|Description|\n|----|----|-----------|\n|name|String|Name of the field or control under which to display the error message.|\n|message|String|Error message to display.|\n\n|Type|Description|\n|----|-----------|\n|None| |\n\n## GlideForm \\(Next Experience\\) - showErrorBox\\(String name, String message, Boolean scrollForm\\)\n\nDisplays 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.\n\nA 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.\n\n<table id=\"table_lyr_dww_ts\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nname\n\n</td><td>\n\nString\n\n</td><td id=\"g_form-showErrorBox-name-entry\">\n\nName of the field or control under which to display the error message.\n\n</td></tr><tr><td>\n\nmessage\n\n</td><td>\n\nString\n\n</td><td id=\"g_form-showErrorBox-message-entry\">\n\nError message to display.\n\n</td></tr><tr><td>\n\nscrollForm\n\n</td><td>\n\nBoolean\n\n</td><td id=\"g_form-showErrorBox-scrollForm-entry\">\n\nFlag that indicates whether to automatically scroll the form to the error message field.Valid values:\n\n-   true: Scroll to the error message field.\n-   false: Don't scroll to the error message field.\n\nDefault: true\n\n</td></tr></tbody>\n</table>|Type|Description|\n|----|-----------|\n|None| |\n\n## GlideForm \\(Next Experience\\) - showFieldMsg\\(String field, String message, String type\\)\n\nDisplays 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.\n\nA 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\\).\n\nThe showErrorBox\\(\\) method is a shorthand method that does not require the type parameter.\n\n**Note:** This method does not work with the **journal\\_field** type field in Core UI.\n\n<table id=\"table_u3z_hxw_ts\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nfield\n\n</td><td>\n\nString\n\n</td><td id=\"g_form-showFieldMsg-field-entry\">\n\nName of the field or control under which to display the message.\n\n</td></tr><tr><td>\n\nmessage\n\n</td><td>\n\nString\n\n</td><td id=\"g_form-showFieldMsg-message-entry\">\n\nMessage to display.\n\n</td></tr><tr><td>\n\ntype\n\n</td><td>\n\nString\n\n</td><td id=\"g_form-showFieldMsg-type-entry\">\n\nType of message.Valid values:\n\n-   error\n-   info\n-   warning\n\n</td></tr></tbody>\n</table>|Type|Description|\n|----|-----------|\n|None| |\n\n```\ng_form.showFieldMsg('impact','Low impact response time can be one week','info');\n```\n\n## GlideForm \\(Next Experience\\) - showFieldMsg\\(String field, String message, String type, Boolean scrollForm\\)\n\nDisplays 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.\n\nA 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\\).\n\nThe showErrorBox\\(\\) method is a shorthand method that does not require the type parameter.\n\n**Note:** This method does not work with the **journal\\_field** type field in Core UI.\n\n<table id=\"table_wmr_gyw_ts\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nfield\n\n</td><td>\n\nString\n\n</td><td id=\"g_form-showFieldMsg-field-entry\">\n\nName of the field or control under which to display the message.\n\n</td></tr><tr><td>\n\nmessage\n\n</td><td>\n\nString\n\n</td><td id=\"g_form-showFieldMsg-message-entry\">\n\nMessage to display.\n\n</td></tr><tr><td>\n\ntype\n\n</td><td>\n\nString\n\n</td><td id=\"g_form-showFieldMsg-type-entry\">\n\nType of message.Valid values:\n\n-   error\n-   info\n-   warning\n\n</td></tr><tr><td>\n\nscrollForm\n\n</td><td>\n\nBoolean\n\n</td><td id=\"g_form-showFieldMsg-scrollForm-entry\">\n\nFlag that indicates whether to automatically scroll the form to the message field.Valid values:\n\n-   true: Scroll to the message field.\n-   false: Don't scroll to the message field.\n\nDefault: true\n\n</td></tr></tbody>\n</table>|Type|Description|\n|----|-----------|\n|None| |\n\n```\ng_form.showFieldMsg('impact','Low impact not allowed with High priority','error',false);\n```\n\n## GlideForm \\(Next Experience\\) - showRelatedList\\(String listTableName\\)\n\nDisplays the specified related list on the form.\n\nThis method isn't available on the mobile platform. If this method is run on a mobile platform, no action occurs.\n\n|Name|Type|Description|\n|----|----|-----------|\n|listTableName|String|Name of the related list to display.|\n\n|Type|Description|\n|----|-----------|\n|None| |\n\n## GlideForm \\(Next Experience\\) - showRelatedLists\\(\\)\n\nDisplays all the form's related lists.\n\nThis method isn't available on the mobile platform. If this method is run on a mobile platform, no action occurs.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|None| |\n\n## GlideForm \\(Next Experience\\) - submit\\(\\)\n\nSaves the record.\n\nThe user is taken away from the form, returning them to where they were.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|None| |\n\n## GlideForm \\(Next Experience\\) - submit\\(String verb\\)\n\nPerforms the specified UI action.\n\n|Name|Type|Description|\n|----|----|-----------|\n|verb|String|An action\\_name from a sys\\_ui\\_action record. The action name must be for a visible form button.|\n\n|Type|Description|\n|----|-----------|\n|None| |\n\n## GlideForm \\(Next Experience\\) - toggleAnnotations\\(\\)\n\nHides or shows all annotations on the form.\n\n[Annotations](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/platform-administration/configure-form-layout.md) 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:\n\n-   [GlideForm \\(Next Experience\\) - hideAnnotation\\(String name\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/GlideFormAPINX.md)\n-   [GlideForm \\(Next Experience\\) - showAnnotation\\(String name\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/GlideFormAPINX.md)\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|None| |\n\nThe 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.\n\n```\ng_form.toggleAnnotations();\n```\n\n"}}