Context menu not working properly

Pravallika9
Tera Expert

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.

1 ACCEPTED SOLUTION

DrewW
Mega Sage
Mega Sage

Also if you need the table name right in the script, you have that in your script using g_list.tableName.

View solution in original post

3 REPLIES 3

DrewW
Mega Sage
Mega Sage

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

 

DrewW
Mega Sage
Mega Sage

Also if you need the table name right in the script, you have that in your script using g_list.tableName.

Pravallika9
Tera Expert

Thanks Drew, it worked using g_list.tableName