Skip to content
Release: Australia · Updated: 2026-03-12 · Official documentation · View source

onShow script for list context menus

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:

VariableDescription
g_menuContext menu to be displayed.
g_itemCurrent context menu item.
g_listGlideList2 against which the script runs.
g_fieldNameName of the field against which the context menu runs.
g_fieldLabelLabel of the field against which the context menu runs.
g_sysIdThe sys_id of the row or form against which the script runs.

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);
}