GlideModal - Client

  • Release version: Washingtondc
  • Updated February 1, 2024
  • 2 minutes to read
  • 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 GlideWindow and GlideDialogWindow.
    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 The UI page to load into the modal.
    readOnly Boolean When true, hides the close button.
    width Number The width in pixels.

    The maximum width is 900 pixels.

    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 The title to be displayed
    Table 15. Returns
    Type Description
    void
    var gm = new GlideModal('UI_dialog_name');
    
    //Sets the dialog title
    gm.setTitle('Show title');
    gm.setPreference('name', 'value');
     			      	        
    //Opens the dialog
    gm.render(); 
    

    GlideModal - setWidth(Number width)

    Set the width in pixels.

    The modal is boxed into predefined system sizes.

    Table 16. Parameters
    Name Type Description
    width Number The number of pixels.

    The maximum width is 900 pixels.

    Table 17. Returns
    Type Description
    void
    var gm = new GlideModal('UI_dialog_name');
    
    //Sets the dialog title
    gm.setTitle('Show title'); 
    gm.setPreference('name', 'value'); 			      	
    gm.setWidth(550);
    
    //Opens the dialog
    gm.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