Integration with third party app (The Drink Exchange)

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:

1 Like