GlideForm (Next Experience) - Client
The GlideForm API provides methods to customize forms in the Next Experience UI Framework.
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.
There is no constructor for the GlideForm class. Access GlideForm methods using the g_form global object.
Parent Topic:Client Next Experience API reference
GlideForm (Next Experience) - addAdditionalParams(String parameterName, String value)
Adds a hidden input with given name and value parameter to the form.
| Name | Type | Description |
|---|---|---|
| parameterName | String | Name of the parameter to add. |
| value | String | Value of the parameter to add. |
| Type | Description |
|---|---|
| None |
The 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.
// Create an onLoad client script for the incident table with the following script.
function onLoad() {
g_form.addAdditionalParam('view_name', g_form.getViewName());
}
Edit the global sysverb_update UI action and add the following script.
current.update();
if (RP.getParameterValue("view_name") == "advanced") {
// Keep the record open if saving from the advanced view
action.openGlideRecord(current);
// To test:
// Open the incident list and edit an incident. Click Update to be redirected to the list.
// Open /incident_list.do?sysparm_view=advanced and edit an incident. Click Update to be redirected back to the edited incident.
GlideForm (Next Experience) - addChoice(String fieldName, String choiceValue, String choiceLabel)
Adds a choice to the end of a specified choice list field.
| 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. |
| Type | Description |
|---|---|
| None |
g_form.addChoice('priority', '6', '6 - Really Low');
GlideForm (Next Experience) - addDecoration(String fieldName, String icon, String title)
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.
| 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 |
| title | String | Title for the icon. |
| Type | Description |
|---|---|
| None |
g_form.addDecoration('caller_id', 'icon-star', 'preferred member');
GlideForm (Next Experience) - addDecoration(String fieldName, String icon, String title, String color)
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.
| 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 |
| title | String | Title for the icon. |
| color | String | CSS color. |
| Type | Description |
|---|---|
| None |
g_form.addDecoration('caller_id', 'icon-star', 'Mark as Favorite', 'color-green');
GlideForm (Next Experience) - addErrorMessage(String message)
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.
| Name | Type | Description |
|---|---|---|
| message | String | Message to display. |
| Type | Description |
|---|---|
| None |
g_form.addErrorMessage('This is an error');
GlideForm (Next Experience) - addFormMessage(String message, String type, Object options)
Displays a floating form message at the top of the form detail section. The message doesn't cover UI actions.
See also:
| Name | Type | Description |
|---|---|---|
| message | String | Message to display. |
| type | String | Type of message.Valid values: - error - info - warning |
| options | Object | Optional. Buttons to add to the form message and any metadata needed to handle a button click. |
| options.buttons | Array | List of buttons to add to the form message. |
| 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 actionNameassign_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. For example, for an Assign to me button the event handler needs the sys_id of the user to assign the record to. |
| Type | Description |
|---|---|
| None |
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 (Next Experience) - addInfoMessage(String message)
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.
| Name | Type | Description |
|---|---|---|
| message | String | Message to display. |
| Type | Description |
|---|---|
| None |
g_form.addInfoMessage('The top five fields in this form are mandatory');
GlideForm (Next Experience) - addHighMessage(String message)
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.
| Name | Type | Description |
|---|---|---|
| message | String | Message to display on the form. |
| Type | Description |
|---|---|
| None |
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 (Next Experience) - addLowMessage(String message)
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.
| Name | Type | Description |
|---|---|---|
| message | String | Message to display on the form. |
| Type | Description |
|---|---|
| None |
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 (Next Experience) - addModerateMessage(String message)
Displays a moderate 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.
| Name | Type | Description |
|---|---|---|
| message | String | Message to display on the form. |
| Type | Description |
|---|---|
| None |
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 (Next Experience) - addOption(String fieldName, String choiceValue, String choiceLabel)
Adds a choice to the end of a specified choice list field.
| 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. |
| Type | Description |
|---|---|
| None |
g_form.addOption('priority', '6', '6 - Really Low');
GlideForm (Next Experience) - addOption(String fieldName, String choiceValue, String choiceLabel, Number choiceIndex)
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.
| 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. |
| Type | Description |
|---|---|
| None |
g_form.addOption('priority', '2.5', '2.5 - Moderately High', 3);
GlideForm (Next Experience) - addSuccessMessage(String message)
Displays a message confirming a successful action at the top of the form.
This message appears for approximately four seconds and then disappears. This timeout is not configurable at this time.
| Name | Type | Description |
|---|---|---|
| message | String | Success message to display. |
| Type | Description |
|---|---|
| None |
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 (Next Experience) - clearAllFormMessages()
Removes all form messages of any type.
See also:
- GlideForm (Next Experience) - addFormMessage(String message, String type, Object options)
- GlideForm (Next Experience) - clearMessages()
- clearFormMessages()
| Name | Type | Description |
|---|---|---|
| None |
| Type | Description |
|---|---|
| None |
The following example shows how to clear all messages from the form.
g_form.clearAllFormMessages();
GlideForm (Next Experience) - clearChoices(String fieldName)
Removes all choices in a specified choice list field.
| fieldName | String | Name of the field for which to clear the full list of choices. |
| Type | Description |
|---|---|
| None |
g_form.clearChoices('priority');
GlideForm (Next Experience) - clearFormMessages(String type)
Removes all form messages of a specified type.
See also:
- GlideForm (Next Experience) - addFormMessage(String message, String type, Object options)
- GlideForm (Next Experience) - clearMessages()
- GlideForm (Next Experience) - clearAllFormMessages()
| Name | Type | Description |
|---|---|---|
| type | String | Type of message.Valid values: - error - info - warning |
| Type | Description |
|---|---|
| None |
The following example shows how to clear all error messages from the form.
g_form.clearFormMessages('error');
GlideForm (Next Experience) - clearMessages()
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().
| Name | Type | Description |
|---|---|---|
| None |
| Type | Description |
|---|---|
| None |
g_form.clearMessages();
GlideForm (Next Experience) - clearOptions(String fieldName)
Removes all options from the specified choice list.
| Name | Type | Description |
|---|---|---|
| fieldName | String | Name of the field for which to clear the choice options. |
| Type | Description |
|---|---|
| None |
g_form.clearOptions('priority');
GlideForm (Next Experience) - clearValue(String fieldName)
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.
| Name | Type | Description |
|---|---|---|
| fieldName | String | Name of the field to clear. |
| Type | Description |
|---|---|
| None |
GlideForm (Next Experience) - disableAttachments()
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.
| Name | Type | Description |
|---|---|---|
| None |
| Type | Description |
|---|---|
| None |
GlideForm (Next Experience) - disableChoice(String fieldName, String choiceValue)
Programmatically disables a specific choice in the drop-down field, if the choice exists. No changes are made if the choice is already disabled.
| 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 |
| 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 |
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 (Next Experience) - enableAttachments()
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.
| Name | Type | Description |
|---|---|---|
| None |
| Type | Description |
|---|---|
| None |
GlideForm (Next Experience) - enableChoice(String fieldName, String choiceValue)
Programmatically enables a specific choice in the drop-down field, if the choice exists. No changes are made if the option is already enabled.
| Name | Type | Description |
|---|---|---|
| fieldName | String | Field name of the choice to enable. |
| choiceValue | String | Value of the choice to enable. |
| 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. Data type: Boolean |
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 (Next Experience) - flash(String fieldName, String color, Number count)
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.
| Name | Type | Description | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| fieldName | String | Field to highlight in the following format: `"| 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 |
GlideForm (Next Experience) - getActionName()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.
GlideForm (Next Experience) - getAnnotations()Returns a list of all annotations on a form. Annotations are visual separators between form elements, or blocks of colored text used to highlight form elements. Use GlideForm (Next Experience) - getAnnotationByName(String name) to return a specific annotation by its name.
The following example first calls getAnnotations() to return all annotations in a form, and then calls hideAnnotation() to hide all annotations in the form. GlideForm (Next Experience) - getAnnotationByName(String name)Returns a form annotation of a given name. Annotations are visual separators between form elements, or blocks of colored text used to highlight form elements. Use GlideForm (Next Experience) - getAnnotations() to return all annotations in a form.
The following example demonstrates how to use the getAnnotationByName() method to retrieve a form annotation according to its given name, test-annotation-msg-1. GlideForm (Next Experience) - getBooleanValue(String fieldName)Returns a Boolean value for the specified field.
GlideForm (Next Experience) - getChoice(String fieldName, String choiceValue)Returns an object with properties representing a given field and choice value.
The following example demonstrates how to call g_form.getChoice() to return information about the GlideForm (Next Experience) - getControl(String fieldName)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 This method is not available in mobile scripts or Service Portal scripts.
GlideForm (Next Experience) - getDecimalValue(String fieldName)Returns the decimal value of the specified field.
GlideForm (Next Experience) - getDisplayValue(String fieldName)Returns the display value from a form in Service Portal. See also: Note: In the core UI, calling this method as
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 site. GlideForm (Next Experience) - getElement(String id)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.
GlideForm (Next Experience) - getFormElement()Returns the HTML element for the form. This method is not available in mobile scripts or Service Portal scripts.
GlideForm (Next Experience) - getIntValue(String fieldName)Returns the integer value for the specified field.
GlideForm (Next Experience) - getLabelOf(String fieldName)Returns the plain text value of the field label.
GlideForm (Next Experience) - getOptions(String fieldName)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:
The following example calls g_form.getOptions() to return all available choices for specified form fields, like state, work_notes_list, and others. The following example script demonstrates how to call g_form.getOptions() with getAvailable() function. GlideForm (Next Experience) - getReference(String fieldName, Function callBack)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.
GlideForm (Next Experience) - getRelatedListNames()Returns an array of related list names from the current form.
GlideForm (Next Experience) - getSectionNames()Returns all section names, whether visible or not.
GlideForm (Next Experience) - getSections()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.
GlideForm (Next Experience) - getTableName()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().
GlideForm (Next Experience) - getUniqueValue()Returns the sys_id of the record displayed in the form.
GlideForm (Next Experience) - getValue(String fieldName)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
The following example shows how to get the short description from the current form. 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]. GlideForm (Next Experience) - hideAllFieldMsgs()Hides all field messages.
GlideForm (Next Experience) - hideAllFieldMsgs(String type)Hides all field messages of the specified type.
GlideForm (Next Experience) - hideAnnotation(String name)Hides an annotation with a given name on the form UI. Annotations are visual separators between form elements, or blocks of colored text used to highlight form elements. See also:
The following example demonstrates how to programmatically hide the annotation named test-annotation-msg-1 on the form field using the hideAnnotation() method. GlideForm (Next Experience) - hideErrorBox(String fieldName)Hides the error message placed by showErrorBox(). Whenever possible, use hideFieldMsg() rather than this method whenever possible.
GlideForm (Next Experience) - hideFieldMsg(String fieldName, Boolean clearAll)Hides the first message that appears in the specified field on the current form. Use the showFieldMsg(String field, String message, String type) or showFieldMsg(String field, String message, String type, Boolean scrollForm) methods to display messages on a form. For example, the following code snippet shows how to display two messages on the
The following example shows how to clear all messages for a specified form field and then display an encryption error message. GlideForm (Next Experience) - hideRelatedList(String listTableName)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.
GlideForm (Next Experience) - hideRelatedLists()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.
GlideForm (Next Experience) - isMandatory(String fieldName)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.
GlideForm (Next Experience) - isNewRecord()Returns true if the record has never been saved.
GlideForm (Next Experience) - isVisible(String fieldName)Determines whether the field associated with the passed-in field name is visible on the current form.
The following code example shows how to check if the GlideForm (Next Experience) - onUserChangeValue(Function fn)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.
GlideForm (Next Experience) - removeChoice(String fieldName, String choiceValue)Removes the specified choice from the specified choice list field.
GlideForm (Next Experience) - removeDecoration(String fieldname, String icon, String title)Removes the icon from the specified field that matches the specified icon and title. Note: This method isn't supported by Service Catalog.
GlideForm (Next Experience) - removeDecoration(String fieldname, String icon, String title, String color)Removes the icon from the specified field that matches the specified icon, title, and color. Note: This method isn't supported by Service Catalog.
GlideForm (Next Experience) - removeOption(String fieldName, String choiceValue)Removes the specified option from the specified choice list.
GlideForm (Next Experience) - save()Saves the record without navigating away (update and stay).
GlideForm (Next Experience) - setChoiceLabel(String fieldName, String choiceValue, String newLabel)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.
The following example calls setChoiceLabel() to update the 'bonus' field choices (10, 20, and 30) to new values. GlideForm (Next Experience) - setDisabled(String fieldName, Boolean disable)Makes the specified field available or unavailable.
GlideForm (Next Experience) - setDisplay(String fieldName, Boolean display)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.
GlideForm (Next Experience) - setLabelOf(String fieldName, String label)Sets the plain text value of the specified field label. Note: This method isn't supported by Service Catalog.
GlideForm (Next Experience) - setMandatory(String fieldName, Boolean mandatory)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. Note: Whenever possible, use a UI policy rather than this method.
GlideForm (Next Experience) - setReadOnly(String fieldName, Boolean readOnly)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() 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
The following example shows how set the Variable Editor to read only. To do this in Service Catalog tables, use setVariablesReadOnly(). GlideForm (Next Experience) - setSectionDisplay(String sectionName, Boolean display)Shows or hides a specified section in the form.
GlideForm (Next Experience) - setValue(String fieldName, String value, String displayValue)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 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. Note: The method setValue() can cause a stack overflow when used in an
The following example shows how to set the short description in the current form. 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]. 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. 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. GlideForm (Next Experience) - setVariablesReadOnly(Boolean isReadOnly)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() method. See also: Service Catalog variable editors
Adding the following line to a client script sets the variable editor to read only. GlideForm (Next Experience) - setVisible(String fieldName, Boolean display)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.
GlideForm (Next Experience) - showAnnotation(String name)Shows an annotation with a given name on the form UI. Annotations are visual separators between form elements, or blocks of colored text used to highlight form elements. See also:
The following example demonstrates how to programmatically show the annotation named test-annotation-msg on the form field using the showAnnotation() method. GlideForm (Next Experience) - showErrorBox(String name, String message)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.
GlideForm (Next Experience) - showErrorBox(String name, String message, Boolean scrollForm)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.
GlideForm (Next Experience) - showFieldMsg(String field, String message, String type)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.
GlideForm (Next Experience) - showFieldMsg(String field, String message, String type, Boolean scrollForm)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 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.
GlideForm (Next Experience) - showRelatedList(String listTableName)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.
GlideForm (Next Experience) - showRelatedLists()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.
GlideForm (Next Experience) - submit()Saves the record. The user is taken away from the form, returning them to where they were.
GlideForm (Next Experience) - submit(String verb)Performs the specified UI action.
GlideForm (Next Experience) - toggleAnnotations()Hides or shows all annotations on the form. Annotations 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:
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. |