---
sourceDocument: Xanadu API Reference
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/xanadu/api-reference

 Release :

    - xanadu

ft:locale :

    - en-US

ft:publication_title :

    - Xanadu API Reference

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# GlideModalForm - Client

# GlideModalForm - Client {#ariaid-title1}

* Release version: Xanadu
* 
* Updated August 1, 2024
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 3 minutes to read

The GlideModalForm API provides methods to display a form in a GlideModal.  
General usage of the GlideModalForm class involves creating the object, setting any preferences, and then rendering the GlideModalForm.

    var dialog = new GlideModalForm('dialog title', 'table_name_or_form_name', [callback on completion of submit])
      dialog.setPreference('name', 'value');
      dialog.render();

Specify the query parameters that are passed to the form using the setPreference() method. Any name/value pair that you specify with setPreference() is sent along with the form POST request to
display the form.

The GlideModalForm is set to fill the height of the document window.

## GlideModalForm - GlideModalForm(String title, String tableName, Function
onCompletionCallback, Boolean readOnly) {#ariaid-title2}

Creates an instance of the GlideModalForm class.
{#r_GMFV3-GlideModalForm_S_S_F_B__table_ikc_xjm_qv__entry__3}

| Name | Type | Description |
|-|-|-|
| title | String | Modal form title. |
| tableName | String | Table being shown. |
| onCompletionCallback | Function | Function to call after the form has been submitted and processed on the server. The callback function has the form`callbackFunction(String action_verb, String sys_id, String table, String displayValue)` where: * action_verb: Name of the UI action executed. Examples are sysverb_insert (Submit button), sysverb_cancel, sysverb_save (Save button). * sys_id: Sys_id of the affected record. * table: Name of the table containing the record. * displayValue: Value that appears on the form. |
| readOnly | Boolean | Optional. Flag that indicates whether the modal form should be set to read only. Valid values: * true: Set form to read only. * false: Set for to read/write. {#r_GMFV3-GlideModalForm_S_S_F_B__ul_rmh_jnx_p4b} Default: false |
[Table 1. Parameters]

{#r_GMFV3-GlideModalForm_S_S_F_B__table_ikc_xjm_qv}  
This example shows how to instantiate a GlideModalForm object.

    function openDevice(deviceSysID, deviceName) {
      var uName = gel('hidden_user_name').value + "'s ";
      deviceName = new String(deviceName).escapeHTML();
      var gp = new GlideModalForm(uName + deviceName, "cmn_notif_device", refreshNotifPage);
      gp.addParm('sys_id', deviceSysID);
      gp.render();
    }

## GlideModalForm - addParm(String name, String value) {#ariaid-title3}

Sets the specified form field to the specified value.
{#r_GMFV3-addParm_S_S__table_tb2_xny_kv__entry__3}

| Name | Type | Description |
|-|-|-|
| name | String | Form field name. If the specified name is not a field in the associated modal form, it is ignored. |
| value | String | Value to set the specified form field to. |
[Table 2. Parameters]

{#r_GMFV3-addParm_S_S__table_tb2_xny_kv} {#r_GMFV3-addParm_S_S__table_ub2_xny_kv__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 3. Returns]

{#r_GMFV3-addParm_S_S__table_ub2_xny_kv}  
This example shows how to call addParm() to set the value of the sys_id
field the modal form.

    function openDevice(deviceSysID, deviceName) {
      var uName = gel('hidden_user_name').value + "'s ";
      deviceName = new String(deviceName).escapeHTML();
      var gp = new GlideModalForm(uName + deviceName, "cmn_notif_device", refreshNotifPage);
      gp.addParm('sys_id', deviceSysID);
      gp.render();
    }

## GlideModalForm - setSysID(String sys_id) {#ariaid-title4}

Sets the object's sys_id preference.
{#r_GMFV3-setSysID_S__table_krd_1ly_kv__entry__3}

| Name | Type | Description |
|-|-|-|
| sys_id | String | The id preference. One of the query parameters passed to the form. |
[Table 4. Parameters]

{#r_GMFV3-setSysID_S__table_krd_1ly_kv} {#r_GMFV3-setSysID_S__table_lrd_1ly_kv__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 5. Returns]

{#r_GMFV3-setSysID_S__table_lrd_1ly_kv}  
This example shows how to use the setSysID() method to initialize the
value of the sys_id.

    function(startDate, endDate) {
      var dialog = new GlideModalForm("Add Schedule Item", "cmn_schedule_span");
      dialog.setSysID("-1");
      dialog.addParm("sysparm_collection", "cmn_schedule");
      dialog.addParm("sysparm_collectionID", this.sysId);
      dialog.addParm("sysparm_collection_key", "schedule");
     
      var q = "schedule=" + this.sysId + "^start_date_time="
       + startDate.serializeInUserFormat() + "^end_date_time="
       + endDate.serializeInUserFormat() + "^";

      if (startDate.isAllDay(endDate))
        q += "^all_day=true^";
     
      dialog.addParm("sysparm_query", q);
      dialog.render();
    }

## GlideModalForm - setCompletionCallback(Function callbackFunction) {#ariaid-title5}

Sets the function to be called when the form has been successfully submitted and
processed by the server.
{#r_GMFV3-setCompletionCallback_F__table_aqr_ply_kv__entry__3}

| Name | Type | Description |
|-|-|-|
| callbackFunction | Function | Callback function to call when the form has been successfully processed. The callback function has the form `callbackFunction(String action_verb, String sys_id, String table, String displayValue)` where: * action_verb: action_name from a sys_ui_action record * sys_id: Sys_id of the affected record * table: Name of the table containing the record * displayValue: Value that appears on the form {#r_GMFV3-setCompletionCallback_F__ul_udl_4jy_kv} |
[Table 6. Parameters]

{#r_GMFV3-setCompletionCallback_F__table_aqr_ply_kv} {#r_GMFV3-setCompletionCallback_F__table_bqr_ply_kv__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 7. Returns]

{#r_GMFV3-setCompletionCallback_F__table_bqr_ply_kv}  
This example shows how to set the onload callback function of the associated modal.

    function handleCreateOrEdit(targetFieldName, sourceFieldName, adapterRuleId, transformerSysId){
      dialog = new GlideModalForm('Edit Adapter Rule', "sys_adapter_rule");
      dialog.setSysID(adapterRuleId); //Pass in sys_id to edit existing record
      dialog.addParm('sysparm_form_only', 'true'); //Add or remove related lists
      dialog.setOnloadCallback(hideModalForm);
      dialog.setCompletionCallback(handleAdapterCreatedOrUpdated);
      dialog.render(); //Open the dialog
    }
    function handleAdapterCreatedOrUpdated(action_verb, sys_id, table, displayValue) {
      var draftRecordTransformer = g_form.getValue("draft_record_transformer");
      if(draftRecordTransformer == null || draftRecordTransformer.length == 0) {
        //sync Sticky Replications if it is enabled.
        var ajax = new GlideAjax('ReplicationPoolUtil');
        ajax.addParam('sysparm_name', 'syncStickyReplicationSet');
        ajax.addParam('sysparm_entry_set', g_form.getValue("entry_set"));
        ajax.getXMLWait();
      }
    }

## GlideModalForm - setOnloadCallback(Function callbackFunction) {#ariaid-title6}

Sets the function to be called after the form has been loaded.
{#r_GMFV3-setOnloadCallback_F__table_uqr_qmy_kv__entry__3}

| Name | Type | Description |
|-|-|-|
| callbackFunction | Function | Function to call after the form has been loaded. The callback function has the form `callBackFunction(GlideModalForm obj)` |
[Table 8. Parameters]

{#r_GMFV3-setOnloadCallback_F__table_uqr_qmy_kv} {#r_GMFV3-setOnloadCallback_F__table_vqr_qmy_kv__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 9. Returns]

{#r_GMFV3-setOnloadCallback_F__table_vqr_qmy_kv}  
This example shows how to set the on load callback function of the associated modal.

    function handleCreateOrEdit(targetFieldName, sourceFieldName, adapterRuleId, transformerSysId){
      dialog = new GlideModalForm('Edit Adapter Rule', "sys_adapter_rule");
      dialog.setSysID(adapterRuleId); //Pass in sys_id to edit existing record
      dialog.addParm('sysparm_form_only', 'true'); //Add or remove related lists
      dialog.setOnloadCallback(hideModalForm);
      dialog.setCompletionCallback(handleAdapterCreatedOrUpdated);
      dialog.render(); //Open the dialog
    }

## GlideModalForm - render() {#ariaid-title7}

Shows the modal form.
{#r_GMFV3-render__table_upp_jny_kv__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 10. Parameters]

{#r_GMFV3-render__table_upp_jny_kv} {#r_GMFV3-render__table_vpp_jny_kv__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 11. Returns]

{#r_GMFV3-render__table_vpp_jny_kv}  
This example shows how to call render() to display the modal.

    function openDevice(deviceSysID, deviceName) {
      var uName = gel('hidden_user_name').value + "'s ";
      deviceName = new String(deviceName).escapeHTML();
      var gp = new GlideModalForm(uName + deviceName, "cmn_notif_device", refreshNotifPage);
      gp.addParm('sys_id', deviceSysID);
      gp.render();
    }


