- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-07-2022 07:22 AM
Hi,
I have created a "update all" context menu by copying the same one from the OOB one which is present.
But when I am trying using the menu it is not performing any action.
whereas for previous on "Update All" when i click i get a alert whether you want to proceed or not.
/**
* Script executed on the Client for this menu action
*
* The following variables are available to the script:
* 'g_list' the GlideList2 that the script is running against (only valid for List context menus)
* 'g_fieldName' the name of the field that the context menu is running against (only valid for List context menus)
* 'g_fieldLabel' the label of the field that the context menu is running against (only valid for List context menus)
* 'g_sysId' the sys_id of the row or form that the script is running against
* 'rowSysId' is also set to the sys_id of the row to support legacy actions, but g_sysId is preferred
*/
runContextAction();
function runContextAction() {
if(ListProperties.getTable() == 'cmdb_ci_appl'||ListProperties.getTable() == 'cmdb_ci_service'||ListProperties.getTable() == 'cmdb_ci_computer'||ListProperties.getTable() == 'cmdb_ci_peripheral'||ListProperties.getTable() == 'cmdb_ci_server'||ListProperties.getTable() == 'cmdb_ci_win_server'||ListProperties.getTable() == 'cmdb_ci_ip_router'||ListProperties.getTable() == 'cmdb_ci_ip_switch'){
var url = new GlideURL(g_list.tableName + '_update.do');
url.addParam('sys_action', 'sysverb_multiple_update');
url.addParam('sysparm_multiple', 'true');
url.addParam('sysparm_nostack', 'yes');
url.addParam('sysparm_query', g_list.getQuery({fixed: true}));
url.addParam('sysparm_view', g_list.getView());
var msg = ['Update the entire list?', 'records'];
var answer = new GwtMessage().getMessages(msg);
if (!confirm(answer['Update the entire list?'] + " (" + g_list.grandTotalRows + " " + answer['records'] + ")"))
return;
window.location = url.getURL();
} }
Please help here.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-07-2022 07:41 AM
Also if you need the table name right in the script, you have that in your script using g_list.tableName.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-07-2022 07:37 AM
Have you looked at the browser console to see if there is a client script error being logged? When I run it I see
Error running context menu 'Update All': ReferenceError: ListProperties is not defined

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-07-2022 07:41 AM
Also if you need the table name right in the script, you have that in your script using g_list.tableName.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2022 11:45 PM
Thanks Drew, it worked using g_list.tableName