xTuple.com xTupleU Blog & News Customer Support

Scripting - Modify Popup Menu

Hi,

I like to add some new functionality to the works order schedule screen. I’d like to add it to the context menu but I can’t seem to figure out how to access this object in scripting. Can anyone help out here?

Regards,

Martin

I assume you mean the right-click context menu of an object in the works order screen!?

If so try the following:

First you have to identify the technical name of the works order schedule screen. I did this by downloading the xTuple client source code and searching for an appropriate term on the screen. This lets you know how to attach scripted code to the screen. Once you know the technical name of the screen create a script with the same name as the screen and probably increase the script order above zero so it runs after the standard code.

I used the following to add a custom menu item to the existing context menu on the G/L transactions screen. It only displays the menu option under some circumstances and passes the G/L transaction details to another custom screen.

var _list = mywindow.list();
_list[“populateMenu(QMenu *,XTreeWidgetItem *, int)”].connect(populateMenu);

function populateMenu(pMenu, pItem, pCol)
{
var pMenu;
var mCode;
if(pMenu == null)
pMenu = _list.findChild("_menu");
if (pItem.rawValue(“gltrans_doctype”).toString() == “VO”
&& pItem.rawValue(“notes”).indexOf(“VISA”) != -1)
{
var voucher = pItem.rawValue(“gltrans_doctype”).toString();
mCode = toolbox.menuAddAction(pMenu, qsTr(“View Visa Transactions…”),true);
mCode.triggered.connect(visaTransaction);
}
}

function visaTransaction()
{
try
{
var pItem = _list.currentItem();
var voucher = pItem.rawValue(“docnumber”).toString();
var childwnd = toolbox.openWindow(“visaTransactionDetails”,mywindow, 0, 1);
var wparams = new Object;
wparams.voucher = voucher;
var tmp = toolbox.lastWindow().set(wparams);
}
catch(e)
{
print(e);
toolbox.messageBox(“critical”, mywindow, mywindow.windowTitle, e);
}
}

Notice in the script above: var tmp = toolbox.lastWindow().set(wparams);

This is the mechanism for passing information to the called script.

look at \share\sample_scripts\resources\client\scripts\itemSiteViewItem.js
in the source code for more information.

In fact that you should peruse the entire directory.

Hi,

Do you know how to set to visible all the available privilege of a user instead of becoming disabled.