Dynamic Lists for UI Context menus based on Row Selected
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2024 11:23 AM
We are building a list of actions to run based on a list view row when we right click. These are all built using UI Context menus, with appropriate onShow and Action Scripts. It is important to note that these are both client-side scripts.
We would like to dynamically add options BASED ON the line that you right-click on. So for example, if I click on the top server, I get:
Now, 'Decommission System' and 'Request Resource Reduction' are regular UI Context Actions, with an onShow script that determines if they are active or not (reflected in the bold versus grayed out options above). The action taken when one is clicked is written in the 'Action Script' field.
But, the 'Show Related Problem Tasks PTASKxxxxxxxxx' are dynamic and should load as many items as exist. In this case, the selected Server has 3 related PTasks, so I created 3 Context Menu Items using the 'Dynamic Actions Script' field.
The problem is, that the 'Dynamic Actions Script' is server side, and does not expose any variables that deal with the selected line you right clicked on. The 'Action Script' and the 'onShow Script' both are client side do expose the needed variable:
* 'g_sysId' the sys_id of the row or form that the script is running against
In other words, the exact same 3 PTASK lines show up regardless of which server I right-click on. It does not know the sys_id of the selected line to use in a filter or query to limit the results.
So, how can I dynamically show additional context menu items that are based on the line that I right-clicked on? Is there a hidden variable as part of the 'Dynamic Actions Script'? Or, is there a different way to do it?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2024 07:21 PM
Hello @blittle,
Please refer to the link below:
https://docs.servicenow.com/bundle/washingtondc-platform-administration/page/administer/navigation-a...
If it is helpful, please mark it as helpful and accept the correct solution.
Thanks & Regards,
Abbas Shaik