Fire an action when new orderS


Some help would be appreciated for the following:

I’d like to fire a DOS batch file when new orderS (plural) are sent, let’s say, to the printers, so After Ticket Closing IF the ticket contains NEW orders.


  • I don’t want to fire any action if the ticket has been opened and then closed without new order been added
  • I want to fire 1 action for all new orders with same OrderNumber. One action for new order “Coca-cola + Cafe”.
  • The input of the DOS batch file would be the OrderNumber.
  • SambaPOS should launch the DOS batch file and then continue, it may not wait for the process to end and only then continue.


  • Order Added to Ticket rule will fire the action for each new order added to the ticket? I mean I add a cafe, action fired, without closing the ticket (same order) I add a coca-cola, action is fired again?
  • Actually it should fire the action the exact same way it sends the order tickets to the kitchen/bar printers, when new orders and/or order updated (void, gift, …)
  • Why DOS batch file? it is actually bash (WSL) just because I am familiar with linux scripting and not with Basic.

Thanks a lot,


Order added event is right out. You’ll then need to account for order cancelled, quantity changed, order tagged/untagged, etc.

I’m not quite sure how one is going to get the current, new order # to pass as command line arguments.

An option would be to constrain a rule when ticket status is “New Orders” and new order count > 0. There’s a report tag for order numbers, {ORDER NUMBERS}, which is comma deliminated. You could pass that as an argument then split on ',' and grab the last item in the array for the newest order. I’m also not quite sure at what point of ticket closing the order # is assigned.

Another option would be having a web api self-hosted and then use the URL printer to send order numbers to it that would more closely match how orders a dispatched to printers (as configured).

Another thing to consider is a terminal window popping up every time a new process is started from SambaPOS. With a console application there are ways to make it run out of focus or completely hide the window all together. I know one can run a batch shortcut minimised, but I don’t think there’s a direct way to make the bat or cmd script run minimised.

Something else that came to mind:depending on what you want to do externally, you may run into a race condition where the external script has the order number, but won’t find it in the db as it hasn’t been committed yet.

Thanks Memo,

It gives me some hints, I’ll try.

Neither am I, trying…


I thought this Use Shell Execute or Is Hidden could do the trick … no idea, I will try, I let you know.

UseShellExecute would be akin to typing “c:\something.txt” or “” in the run dialog box.

A report expression before ticket closing also a posability, checking status and gstate.

Cha ge quantity shouldnt effect as dont think you can change quantitiy on previously submitted orders.

Ok giving up.

  1. cannot make wsl.exe or bash.exe (64bits) work when fired from SambaPOS(32bits?)'s rule. Scripts works well when executed from cmd (64bits).
  2. It was anyway a stupid idea because I have 4 terminals and these scripts must be implemented in the 4 computers, making maintenance difficult.

So let’s do it from SambaPOS itself.

64/32bit shouldn’t matter - SambaPOS use Process.Start() which tells the OS to launch the application.

Could you describe what is the end result? What is needed to be done with the order #? Maybe there’s another option we can explore.

So let’s do it from SambaPOS itself:

  1. linked Oracle database in Ms SQLServer.
    Bug in OraOLEDB.Oracle for SELECT but INSERT works
  2. Use a script to write data to Oracle’s order table.
function newOrder(settingname) {
  var qry = "INSERT INTO [ORACLE106]..[OBE].[ABI_PEDIDOS] \
             ([Nombre]) \
             VALUES \
  var r = sql.ExecSql(qry);
  return qry;

Now it’s only SambaPOS related programming, which I am not too good at.
I need to fetch:


  • Ticket Closing


  • new Orders’s details (O.Id, O.ItemName, OrderNumber, T.Entities, etc …) one by one
  • void Orders’s details (O.Id) one by one
  • Order TAG’s Details (O.Id, T.Values) to insert in Oracle’s Ordertag table.

using, as arguements {ORDER DETAILS:O.Id, O.MenuItemName, ...:FILTERS} or {ORDER TAG DETAILS:X}

Some questions

  • I suppose that Using Order Added to Ticket rule works like this:
    coca added-> fire rule
    adding “1” coca, so 2 en total → fire rule
    Cancel a coca → fire rule,
    etc …
    Is it so?
  • One by one = Jscript loop? or Multiple INSERT (no idea how, though)?
  • So for new orders, which filter (like ODI, MG, …) should I use to get only the NEW orders?
  • So for void orders, which filter (like ODI, MG, …) should I use to get only the VOID orders?
  • Which Action or Rule Constraints should I use to only run the actions/rule if there is actually a new order or a void order? So to avoid running the rule if ticket is open and closed, just to look the bill.
  • In Ticket Closing Rule, Order State changes from New to Submitted, so should I put my actions in Before Closing Ticket rule?

My Jscript skill: able to copy/paste and adapt existing code.

What about a trigger on the dbo.Orders table after insert, insert the order id into the linked Oracle table?


I was on it since January (not every day though, I have a work)!! I gave up!
I could not use a basic trigger cause any problem would hang SambaPOS.
So I went with asynchronous trigger (Service Broker and stored procedure).
My Stored procedure was fine in the SSMS console but failed when triggered by Insert on Orders Tables.

The restaurant is working 7/7 and from 7am to 2 am. So it’s really difficult to program/test/debug on a running system. I gave up.

Even a normal trigger failed on a basic insert on the linked oracle database.

Create another table (like NewOrders or OrdersToParse, etc) - same or different schema, doesn’t matter.

Have the after insert trigger insert into that table. Then, have something that polls the SambaPOS db and queries the new order table then insert into the Oracle db, deleting those records from the SambaPOS db. This should allow you to use a native Oracle adapter instead of interop with MSSQL.

The restaurant is working 7/7 and from 7am to 2 am. So it’s really difficult to program/test/debug on a running system. I gave up.

This should all be testing in a dev environment. Spin up a VM with everything you need - MSSQL, Oracle, SambaPOS, etc. with databases to match.

I’d like but I guess i’ll have problem with the licence, no?
If I restore the db on a VM, licence will be included and if I “unregistered”, I’ll not be able to work, isn’t it so?

That’s why my first post.
“Have something that pull out from SQLServer and pull in Oracle”. That part works on my own computer Get from SambaPOS and put in Oracle; linux, bash script, sqlcmd + sqlplus.

I just wanted to put these scripts on SambaPOS server instead of my own machine.
Less compu, less problems. But using DOS batch calling WSL script gave me problems and I have 4 terminals, start process not convenient.

That’s why, now, I try from inside the SambaPOS application, in JScript, and the sql part is fine, I just need to figure out how to get, one at the time, the new orders to process it to Oracle.

I want real-time, I don’t want “Check every minute if there are new orders in the temporary table” so using a sambapos rule seems perfect.

SambaPOS5 is installed on a windows machine.
Oracle (XE) + Apex is installed on a linux machine, and that’s where all administration apps are (accountancy, HR, recipes, and now - what I try to do - kitchen display)

Before ticket closing, if there are new orders ({ORDER STATE QUANTITY TOTAL:New} I think would work) then the last id in the comma-separated list of {ORDER NUMBERS} would be the latest order. You can use that craft your select statement in MSSQL to then insert whatever is needed into Oracle.

I’m thinking of something in between - a web api that receives a request with the order numbers, grabs the last one, selects the ticket, order information from the SambaPOS database, then inserts into the Oracle db (checking, of course, if the order exists yet). You’d only have to host the api on one machine, and, with a script point request to the machine hosting it.

You’ll have to deal with the popups like (I imagine) we all do.