And code wise the scripts are just jscript and google will reviel answers on how to do most things within the script itself.
Hi Mark,
are you prepared to share this script with me.
Yes I have found info on the forum but its very scattered.
What I would like is when I press a item button the screen that the item id is picked up and I can go to the database with this and return the price.
Thanks in advance.
Stuart
I can share the script and basic setup for that specific system, but you will of course need to modify the script for your needs - for one, you will need to add code to do a SQL query from the database to retrieve the price. You can probably use the sql.Query()
function.
Read more about JScript helper functions available here:
Script:
function getPrice(menuItemId) {
var newPrice = null;
var f = 'file://///POS1/Samba/drinklist.json';
if (menuItemId > 0) {
var data = web.Download(f);
var priceList = JSON.parse(data);
var checkPrice = eval('priceList.id' + menuItemId);
if (checkPrice) {
newPrice = checkPrice;
}
}
return newPrice;
}
Action:
Rule:
Thousand thank Mark,
Its so clear how it works and clever. I’m recommending SAMBA to all new clients, its a powerful product but confiiguration is heavy.
Thanks again!
Stuart
Hi mark,
I added my own script to scripts, what is the handler definition? ‘Order Added to Ticket’ ?
Regards,
Stuart
The script name can be anything you want - it is just for display purposes.
The handler is what you use to call the script, it should follow the same syntax as a function / variable name - so no spaces, etc. So for example, my script handler was tde
, and if you look at the Rule, you will see I call the function using the handler name then function name:
{CALL:tde.getPrice({ITEM ID})}
Thousand thank Mark,
Its so clear how it works and clever. I’m recommending SAMBA to all new clients, its a powerful product but confiiguration is heavy.
I assume getPrice is the name of the script an tde is the handle?!
Thanks again!
Stuart
getPrice is the function. tde is the handler.