xTuple.com xTupleU Blog & News Customer Support

Display additional info when deleting Sales Order on openSalesOrders screen

Good afternoon,

When you right-click a sales order from the Open Sales Orders screen and choose Delete, the system displays a generic “Are you sure you want to completely delete the selected Sales Order? Yes|No” pop-up. We’ve had a couple of instances where users have picked the wrong sales order and unthinkingly clicked Yes and deleted an order we want to keep. The prompt is hardcoded into the deleteSalesOrder() function in salesOrders.cpp, called from openSalesOrders.cpp. So, I’m trying to get the system to display a “prompt before the prompt” that will provide details about the order that the user will have to acknowledge before getting the core generic prompt. However, the delete action in openSalesOrders is a menu action that directly calls deleteSalesOrder, not a typical signal that I can call a coreDisconnect when triggered. Or, I should say, I don’t know how to call a coreDisconnect off the selection of a right-click menu action. Is it possible to have an openSalesOrders.js script that will recognize the selection of the Delete right-menu item, disconnect to display my detailed prompt, then go back in to run the normal deleteSalesOrder logic if the user confirms the deletion?

Thanks very much.

Short answer is yes it is possible to intercept a menu action and provide your own prompt, then kick back into core function logic.

Here is an example of finding a menu (“Edit Project…” - you have to search the menu by text) and disconnecting the core function, and replacing the menu with your own function

populateMenu = function(pMenu, pItem, pCol)
  var t = pMenu.actions();
  for (var i = 0; i < t.length; i++) {
    if (t[i].text == "Edit Project...") {
      toolbox.coreDisconnect(t[i], "triggered()", mywindow, "sEdit()");

Thanks Dave, that worked perfectly, once I realized I had to put in the higher order xtbatch script for openSalesOrders so that the populateMenu in that script would find and execute it. Thanks very much for your assistance, it’s much appreciated.