GlideModal - Client

  • Release version: Xanadu
  • Updated August 1, 2024
  • 3 minutes to read
  • 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.

    This is a fully-featured replacement for the GlideWindow and GlideDialogWindow APIs.
    Figure 1. Example overlay
    Example overlay

    GlideModal - GlideModal(String id, Boolean readOnly, Number width)

    Creates an instance of the GlideModalV3 class.

    Table 1. Parameters
    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:
    • true: Don't display the close button in the modal.
    • false: Display the close button in the modal.

    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.

    Table 2. Parameters
    Name Type Description
    id String The element id of the GlideModal object.
    Table 3. Returns
    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.

    Table 4. Parameters
    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.
    Table 5. Returns
    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.

    Table 6. Parameters
    Name Type Description
    None
    Table 7. Returns
    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.

    Table 8. Parameters
    Name Type Description
    html String The HTML content to be shown in the modal.
    Table 9. Returns
    Type Description
    void

    GlideModal - setPreference(String name, String value)

    Sets the specified field on the current form to the specified value.

    Table 10. Parameters
    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.
    Table 11. Returns
    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.

    Table 12. Parameters
    Name Type Description
    properties Array An array of name-value pairs to be set.
    Table 13. Returns
    Type Description
    void

    GlideModal - setTitle(String title)

    Sets the title of the modal.

    Table 14. Parameters
    Name Type Description
    title String Title to be displayed
    Table 15. Returns
    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.

    Table 16. Parameters
    Name Type Description
    width Number Number of pixels to set as the width of the modal.

    Maximum: 900 pixels

    Table 17. Returns
    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.

    Table 18. Parameters
    Name Type Description
    newView String The view to use.
    Table 19. Returns
    Type Description
    void