Odd behaviour with wrong rule being triggered

I’ve got an odd issue which appears to trigger the the wrong rule or incorrectly repeats the last rule. I think it’s related to “Execute Automation Command” event. It’s a bit difficult to explain so I’ll explain what I’m doing then what is going wrong - please bear with me! :wink:

I have created a item discount button which uses ask question to enable fixed %, variable % and variable amount discounts all from one button. It works, however in one particular scenario (the “enter amount” discount), I get this odd behaviour.

Here is how it works normally:

From rule debugger, we can see the Execute Automation Command rules are triggered correctly:

image

However, on my “enter amount” discount, the final rule is being triggered 3 times incorrectly, it is most obvious in the error state (where a discount amount is entered that is greater than the product price):

It also triggers 3 times if I enter a valid amount.

I can see from rule debugger, it appears rule “DI Check Amount Discount” is triggered 3 times, which is incorrect - but actually the timing of these events appear in rule debugger even before that event is used.

I have checked my rules and actions thoroughly, deleted and re-created multiple times, changed names, checked the database and I just can’t work out why this is happening?! I have spent the last few hours just trying to make this work correctly!

Below is the process for “enter amount” with a valid value, again you can see it triggers the wrong rule 3 times. You can see the rule debugger window, if you look closely you see the first AutomationCommandExecuted event occurs on the first ask question, and this is before the “DI Check Amount Discount” is ever referenced. I think also this is not being shown correctly in rule debugger as clearly the events before this issue, like the first ask question, appear just be replaced with the incorrect rule.

Here is the rule debugger, you can see the tag order action has been triggered 3 times. In this case it works since it applies, removes then applies the discount, but should not be doing this 3 times.

For clarity, here is the setup I have done:

Automation Commands

image

Actions

image

image

image

image

Rules

image

image

Any idea what is causing this? It’s really frustrating as the functionality works but I can’t use it until I fix this issue.

Hmmm interesting, my post last night about discounts used an execute automation command and I was struggling to work out why I was getting so many test ask questions come up, sounds very similar to your issue.

1 Like

Yeah, sounds like the same identical issue. Check rule debugger also on your setup and probably you will see the events triggering the wrong rule and I believe the multiple number you get is based on the number of times you run AutomationCommandExecuted.

My rule debugger doesnt work, shows blank LOL else I might have realized this before hehe;

That’s helpful! I’m still on 5.2.2. Possibly an issue with 5.2.3?

What version of SQL are you using? I’m using 2017 on this DB but I usually use 2014. Not sure if that’s the issue? I might try exporting the setup to a 2014 DB later and see if it does the same. What’s odd is in the whole time I’ve been using SambaPOS (4+ years now) I never really came across this, and the only main difference with this DB is it’s on 2017.

likewise 2014, its been like it for a while, something on this machine i think.

DB Engine version will not be a factor.

Maybe try re-ordering your DI Rules. Use the search/filter to reduce Rule list to just “DI<space>” and then Sort the Rules to an order which makes sequential sense.

Try Command Value Is Not Null instead of Not Equals <nothing/blank>.

And keep in mind, the Ask Question action and [?Prompt] notation are both “blocking” actions, where execution is stopped before execution of the next Action, which as you know cannot use an Action Constraint from the resulting value of the Ask/Prompt since the answer is not yet known.

1 Like

I’m going to go insane in a moment…

So guess what? It works fine, UNLESS you have Rule Debugger running! If I turn off Rule Debugger then close and open SambaPOS, it works fine. Then turn it back on and it doesn’t work.

This doesn’t really explain for the case JTR mentioned though, especially since his rule debugger isn’t working.

How did this happen? Well, I had an issue with another rule earlier then started rule debugger to investigate that, and since you can’t turn off rule debugger without closing SambaPOS, I just left it running. What an absolute waste of time all because of rule debugger. This is in v5.2.2, not sure if that’s in earlier versions or 5.2.3.

Thanks @QMcKay for your input. I did reorder like you suggested, one was in the wrong order but I think it didn’t matter in this case.

2 Likes

Ive had same issue with auto commane exec and i have rule debugger on all time, i ended up reworking automation to work around just thinkin i was doing something wrong

Ill turn debugger off now lol

There is defiantly issues with rule debugger in 5.2.3…
Just been panicking about planned update at hotel when I noticed some of my rules wern’t triggering, even very basic automation command executed ones with no fancie constraints.
Checked and turning off rule debugger it now seems to be working…

That has been a drawback to rule debugger it is not meant to be running in production. Emre mentioned it once and said it would be too much involved to fix that.

1 Like