[Answered] Discount Tag Order intermittently functioning

@emre, I’ve been spinning in circles trying to get this to work, and sometimes it appears to work, while other times it does not.

It’s almost as though the Program Setting isn’t being read properly after being set for the 1st time. Subsequent attempts on the Order Line work.

Also, I can’t seem to get the product to go back to the original price. Is that because Order.Model.GetVisiblePrice() reads the price on the item in the Ticket as opposed to the actual Product Price? Is there something else I should use instead?

Are you intentionally modifying order’s price? Using Order Tag mechanism allows us to set a negative order tag price without changing order’s original price.

Yes, I’m trying to modify the price, but using a custom amount with the [?Enter Discount Amount] notation. This does work to a certain degree, using Tag Order, and UnTag Order, but I was still running into the same issue with intermittent success. I believe it is because the Update Program Setting Action is not setting the value properly from the [?notation] consistently. Even though my Message Boxes are displaying the entered value properly, my constraints in the Actions that follow do not always work.

The constraints are in place so that if the value entered is zero, then the Order Tag should be removed, and the price should go back to the original.

To be able to go back to original price you should keep orders’s price unchanged. Instead of changing order price use Order Tag Price setting on Tag Order action.

All constraint expressions evaluates at once to determine which actions to execute or not. Action execution starts after that. So changing setting values with actions during execution will not change constraints backwards.

Ok, so you’re saying that my flow of Actions is not going to execute properly, because when the Rule Captures the Event of the Automation Command CLICK, the Action Constraints are not tested sequentially; rather they are tested immediately, and "short-listed" before the Update Program Setting {:CustomDiscountAmount} even has a value… makes sense now, this behavior:

Very good to know. So I need to go about it another way.

Maybe it is time to test our Exeucte Automation Command action. I’ll try to implement similar feature now to see if it performs fine or not.


Can I get an Event for Program Setting Updated/changed/altered? Or is that an expensive event to monitor?

Let me try that solution. If it works like I planned you’ll see we won’t need that since that will work like we configure our custom events.

Hello @QMcKay. Does it works as expected?

data45.zip (114.1 KB)

PS: You don’t need to configure Automation Command to be able to use Execute Automation Command action.

Excuse my ignorance on this subject @emre, but what do I do with this SDF file when I run SQL Express 2012 ?

You can open it via Query analyser and run

@Jesse, you’ve lost me… where is that? Are you suggesting I download SQLCE?

I am sorry aparently MS took out the option after 2012.

You can check to see if its in yours or not but
File: Connect Object Explorer: Change Server Type to SQL Server Compact Edition
From the Database Dropdown select browse for more then open your sdf file.

There may be an easier way if your SQL Express does not support the import but I found this for you… looked like it might work.

Looks like he coded something that will convert the .sdf to scripts you can import and then run yourself via management studio

He provides the code to so you can see exactly what his program is doing if your worried about security.

If you just want to view it there are several programs out there that will open it to view it. I use SDF Viewer

OK No need to install CE, I’ll try to create a SQL Server backup soon.

PS. Sorry for responding a little late. It is holiday in our country and I’m away from home atm.

Can I direct SambaPOS to use the SDF as a datasource without installing CE? I suppose not…

Hello. Sorry for late reply. Let me show few screen shots to demonstrate my idea.

This is Execute Automation Command action. It basically executes an action.

When I select an order and click Discount Button this rule executes.

It asks for [:?Discount Amount] and executes two automation commands. It sets Discount Amount to Command Value.

Hint multiple [?:X] queries executes once.

First automation command Executes Update Discount if Zero command and the other one executes Update Discount if Not Zero command. As you can see we set no constraints here. Since it executes automation commands we can use rule constraints.

Hint: We don’t need to add automation command records for Update Discount… Commands. We can just handle it by writing command name in rule constraint.

This is how Update Discount If Zero Rule configured.

Since I didn’t configured Update Discount if Zero command it will not appear in drop down list but I can type command name there. It simply checks if Command Value (Discount Amount) zero or empty and if so it executes Remove Discount action.

This is how I’ve configured Update Discount if Not Zero rule.

This one adds discount value if something entered other than 0 or nothing. As you can see I’m using [:CommandValue] to calculate discount amount.

I think this is more powerful than using action constraints.

1 Like

I think you’ll wonder what [:Desc] parameter does. Since I’ve enabled Add Order Tag price to Product price setting, discount amount is not visible on order line. This feature called Order Tag Note and it displays custom values next to tag name. This feature is only accessible through Tag Order action and I’ve used this feature to display discount amounts.

When I add $2 discount it appears as…

1 Like

@emre, thanks for the explanation. I have this set up and working fairly well, with 1 exception: when amount entered is 0 (zero), the Order Tag is not removed. Can you explain why this is? (see the screenshot at the very end).