---
sourceDocument: Xanadu ServiceNow AI Platform Administration
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/xanadu/platform-administration

 Release :

    - xanadu

ft:locale :

    - en-US

ft:publication_title :

    - Xanadu ServiceNow AI Platform Administration

ft:clusterId :

    - platadm

bundleId :

    - platadm

workflow :

    - Platform


---

# onShow script for list context menus

# onShow script for list context menus {#ariaid-title1}

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

The onShow script field defines a script that runs before the
context menu is displayed to determine which options appear in the context menu.
Use this script to change the menu items on the list header menu based on the current field column. The following JavaScript variables are available to the onShow script when it is executed:{#r_OnShowScript__table_bjm_n4r_sr__entry__2}

| Variable | Description |
|-|-|
| g_menu | Context menu to be displayed. |
| g_item | Current context menu item. |
| g_list | GlideList2 against which the script runs. |
| g_fieldName | Name of the field against which the context menu runs. |
| g_fieldLabel | Label of the field against which the context menu runs. |
| g_sysId | The sys_id of the row or form against which the script runs. |
[Table 1. onShow script variables]

{#r_OnShowScript__table_bjm_n4r_sr}  
An example of an onShow script is one that determines when to enable or disable the Ungroup option in a list column heading menu based on whether the list is grouped or not.

    if (g_list.getGroupBy()) {
       // list is grouped so enable to Ungroup menu item
       g_menu.setEnabled(g_item);
    } else {
       // list is not grouped, so disable the Ungroup menu item
       g_menu.setDisabled(g_item);
    }


