GlideModal - Client
The GlideModal API provides methods for displaying a content overlay.
Use these methods in scripts anywhere that you can use client-side JavaScript. These methods are most often called from a UI action with the Client check box selected.
GlideModal - GlideModal(String id, Boolean readOnly, Number width)
Creates an instance of the GlideModalV3 class.
| Name | Type | Description |
|---|---|---|
| id | String | UI page to load into the modal. |
| readOnly | Boolean | Flag that indicates whether to hide the close button in the modal. Valid values:
Default: false |
| width | Number | Width of modal in pixels. Default: Maximum width: 900 pixels Note: You can also set the modal width using the GlideModal - setWidth(Number width) method. |
GlideModal - get(String id)
Get a GlideModal object by ID.
| Name | Type | Description |
|---|---|---|
| id | String | The element id of the GlideModal object. |
| Type | Description |
|---|---|
| GlideModal | The object. |
GlideModal - getPreference(String name)
Returns the value of the specified preference (property).
Invoking actions that create the modal typically also create the necessary preferences for the modal using the GlideModal - setPreference(String name, String value) method. The UI page client script then consumes these preferences using this method.
| Name | Type | Description |
|---|---|---|
| name | String | Name of the preference value to retrieve. This value must have previously been set on the modal using the GlideModal - setPreference(String name, String value) method. |
| Type | Description |
|---|---|
| String | Specified preference's value. |
This example shows a simple case of setting a preference and then retrieving that preference from a specified modal.
var gm = new GlideModal('UI_dialog_name');
//Sets the dialog title
gm.setTitle('Show title');
//sets the value of the preference table
gm.setPreference('table', 'incident');
//gets the value of the preference table
var title = gm.getPreference('table');
GlideModal - render()
Renders the UI page in the modal.
| Name | Type | Description |
|---|---|---|
| None |
| Type | Description |
|---|---|
| void |
var gm = new GlideModal("UI_dialog_name");
//Sets the dialog title
gm.setTitle('Show title');
gm.setWidth(550);
//Opens the dialog
gm.render();
GlideModal - renderWithContent(String html)
Display a modal with the specified HTML content.
The renderWithContent() method replaces the render() method, and does not request a UI page to render.
| Name | Type | Description |
|---|---|---|
| html | String | The HTML content to be shown in the modal. |
| Type | Description |
|---|---|
| void |
GlideModal - setPreference(String name, String value)
Sets the specified field on the current form to the specified value.
| Name | Type | Description |
|---|---|---|
| name | String | Name of the form field to update. If this field does not exist on the current form, the request is ignored. |
| value | String | Value to store in the specified form field. |
| Type | Description |
|---|---|
| void |
var gm = new GlideModal('UI_dialog_name');
//Sets the dialog title
gm.setTitle('Show title');
gm.setPreference('table', 'task');
gm.setPreference('name', 'value');
//Opens the dialog
gm.render();
GlideModal - setPreferenceAndReload(Array properties)
Set the properties and reload the modal.
| Name | Type | Description |
|---|---|---|
| properties | Array | An array of name-value pairs to be set. |
| Type | Description |
|---|---|
| void |
GlideModal - setTitle(String title)
Sets the title of the modal.
| Name | Type | Description |
|---|---|---|
| title | String | Title to be displayed |
| Type | Description |
|---|---|
| void |
var dialog = new GlideModal('UI_dialog_name');
//Sets the dialog title
dialog.setTitle('Show title');
dialog.setPreference('name', 'value');
//Opens the dialogdialog.render();
GlideModal - setWidth(Number width)
Sets the width of the modal in pixels.
You can also set the width of a modal when you first instantiate it using the GlideModal - GlideModal(String id, Boolean readOnly, Number width) method.
| Name | Type | Description |
|---|---|---|
| width | Number | Number of pixels to set as the width of the modal. Maximum: 900 pixels |
| Type | Description |
|---|---|
| void |
var dialog = new GlideModal('UI_dialog_name');
//Sets the dialog title
dialog.setTitle('Show title');
dialog.setPreference('name', 'value');
dialog.setWidth(550);
//Opens the dialog
dialog.render();
GlideModal - switchView(String newView)
Change the view and reload the modal.
| Name | Type | Description |
|---|---|---|
| newView | String | The view to use. |
| Type | Description |
|---|---|
| void |