---
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


---

# Dynamic actions script for list context menus

# Dynamic actions 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 Dynamic actions script field, on the Context Menu form,
defines a script. The script populates a list context menu with dynamic options, such as filters
or views.
The following JavaScript variables are available to the dynamic actions script when it is executed.{#r_DynamicActionsScript__table_nyj_nnr_sr__entry__2}

| Variable | Description |
|-|-|
| g_tableName | Name of the current table. |
| g_listId | ID of the list for which the context menu is built. |
| g_itemName | Name defined in the UI context menu record. |
| g_itemOrder | Order defined in the UI context menu record. Use this variable to pass the value of the Order field to the dynamic actions script. |
| g_contextMenu.addAction(item_id, label, script_string, order) | Add options to the context menu and select the order in which they appear. |
[Table 1. Dynamic actions script variables]

{#r_DynamicActionsScript__table_nyj_nnr_sr}  
The following example displays a list title menu item that controls the number of records per page in the list view.

    g_contextMenu.addAction('50', g_itemName, 'showRowsPerPage("50");', g_itemOrder);

Note:  
The action script for this item must define the showRowsPerPage function so that when selecting this menu item, that function is called with an argument of 50.

