Problem with "Execute script" Action

I have an execute script action which does not fire when an Ticket is created from SambaIN.
When I open and close the ticket on the POS itself, it fires correctly.

I tried to put the Action in Ticket Closing rule and in a Before Ticket Closing rule. In both scenarios it does not work with SambaIN and works locally on the terminal. Every other Action which is included in a Ticket Closing or Before Ticket Closing rule works fine.
Am I doing something wrong? Is this by design not working at all or is it a bug?

Not all rules are triggered with graphql. Especially if ticket is paid already.

It is not about rules but actions.
The Ticket Closing Rule is triggered anyway otherwise the execute print job action would not fire.This action works well.

The execute script action does not work.

Is there a list which actions work and which do not work?

In my experience, scripts are not executed when a ticket is created/manipulated via the API.

I have yet to try, but perhaps executeAutomationCommandOnTerminalTicket might work.

However, I don’t know if the ClearScript engine is exposed to the API as it is for the desktop application.

I have a script that is triggered by graphql when ticket is closed, I think that depends of what the script does.

1 Like

Here is the script:

function createVoucher(firstname,lastname,ordervaluestr,deliveryminutesstr,tipstr) {
var resto = “PIR”;
var rand = Math.random(3)*10000;
rand = rand.toString().substring(0,3);
deliveryminutes = parseInt(deliveryminutesstr);
ordervalue = parseFloat(ordervaluestr);
if (tipstr !=’’){
tip = parseFloat(tipstr);
ordervalue = ordervalue-tip;
// return ordervalue;
var deliveryhour = deliveryminutes / 60;
// return deliveryhour;
var hour = parseInt(DateTime.Now.ToString(“HH”))+Math.floor(deliveryhour);
var day = DateTime.Now.ToString(“ddd”);
var cashbackvalue = 0;
var voucher = “”;
var driver = “MySQL ODBC 8.0 Unicode Driver”;
var conString = “Driver={”+driver+"};";
conString += “Server=dbisabdasdsnajkda;”;
conString += “Port=onsiaiodhsioa;”;
conString += “Database=ohdisnadjahio;”;
conString += “Uid=jknkjhio;”;
conString += “Pwd=dsajdadnj”;
conString += “Option=3”;
var conn = new ActiveXObject(“ADODB.Connection”);
var rs = new ActiveXObject(“ADODB.Recordset”);

cashbackvalue = Math.floor(ordervalue*0.3);

if ((hour)>9 && (hour)<15){
cashbackvalue = Math.floor(ordervalue0.5);
if ((hour)>15 && (hour)<23 && ((day)==“Fri”|(day)==“Sat”|(day)==“Sun”)){
cashbackvalue = Math.floor(ordervalue
// return cashbackvalue;
Data.Set(‘voucher’,voucher); = conString;
var aSQLStatement = “INSERT INTO vouchers(firstname,lastname,cashbackvalue,ordervalue,voucher,minutes) VALUES(’”+firstname+"’,’"+lastname+"’,’"+cashbackvalue+"’,’"+ordervalue+"’,’"+voucher+"’,’"+deliveryminutes+"’)";

Why a script and not rules and actions → I have a common database of 6 restaurants and you can redeem afterwards the vouchers in any of those restaurants.

I meant to say not all actions are triggered by graphql sorry. Scripts are not available to run as Memo said.