# \[Answered\] Discount Tag Order intermittently functioning

**URL:** <https://forum.sambapos.com/t/answered-discount-tag-order-intermittently-functioning/1915>\
**Category:** V4 Question\
**Created:** [July 28, 2014, 6:30pm UTC](https://forum.sambapos.com/t/answered-discount-tag-order-intermittently-functioning/1915 "2014-07-28T18:30:55Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![QMcKay](https://forum.sambapos.com/user_avatar/forum.sambapos.com/qmckay/32/27925_2.png) [@QMcKay](https://forum.sambapos.com/u/QMcKay)\
**Post date:** [July 28, 2014, 6:30pm UTC](https://forum.sambapos.com/t/answered-discount-tag-order-intermittently-functioning/1915/1 "2014-07-28T18:30:55Z")

</div>

@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?

 ![](https://forum.sambapos.com/uploads/default/original/3X/f/f/ff86ab982fa06ba1ace5c0a6700abe76382254ab.png)

---

<div class="post-metadata">

**Author:** ![emre](https://forum.sambapos.com/user_avatar/forum.sambapos.com/emre/32/39073_2.png) [@emre](https://forum.sambapos.com/u/emre)\
**Post date:** [July 28, 2014, 6:54pm UTC](https://forum.sambapos.com/t/answered-discount-tag-order-intermittently-functioning/1915/2 "2014-07-28T18:54:10Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![QMcKay](https://forum.sambapos.com/user_avatar/forum.sambapos.com/qmckay/32/27925_2.png) [@QMcKay](https://forum.sambapos.com/u/QMcKay)\
**Post date:** [July 28, 2014, 7:16pm UTC](https://forum.sambapos.com/t/answered-discount-tag-order-intermittently-functioning/1915/3 "2014-07-28T19:16:51Z")

</div>

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.

![](https://forum.sambapos.com/uploads/default/original/3X/6/5/65ead849cb695411e7663320d0d9ed68a7607877.png)

---

<div class="post-metadata">

**Author:** ![emre](https://forum.sambapos.com/user_avatar/forum.sambapos.com/emre/32/39073_2.png) [@emre](https://forum.sambapos.com/u/emre)\
**Post date:** [July 28, 2014, 7:31pm UTC](https://forum.sambapos.com/t/answered-discount-tag-order-intermittently-functioning/1915/4 "2014-07-28T19:31:01Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![QMcKay](https://forum.sambapos.com/user_avatar/forum.sambapos.com/qmckay/32/27925_2.png) [@QMcKay](https://forum.sambapos.com/u/QMcKay)\
**Post date:** [July 28, 2014, 7:39pm UTC](https://forum.sambapos.com/t/answered-discount-tag-order-intermittently-functioning/1915/5 "2014-07-28T19:39:32Z")

</div>

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:

![](https://forum.sambapos.com/uploads/default/original/3X/6/5/65e9debbeeaf8b9faec9f0228f6b86d80c68d901.png)

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

---

<div class="post-metadata">

**Author:** ![emre](https://forum.sambapos.com/user_avatar/forum.sambapos.com/emre/32/39073_2.png) [@emre](https://forum.sambapos.com/u/emre)\
**Post date:** [July 28, 2014, 7:42pm UTC](https://forum.sambapos.com/t/answered-discount-tag-order-intermittently-functioning/1915/6 "2014-07-28T19:42:10Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![QMcKay](https://forum.sambapos.com/user_avatar/forum.sambapos.com/qmckay/32/27925_2.png) [@QMcKay](https://forum.sambapos.com/u/QMcKay)\
**Post date:** [July 28, 2014, 7:43pm UTC](https://forum.sambapos.com/t/answered-discount-tag-order-intermittently-functioning/1915/7 "2014-07-28T19:43:38Z")

</div>

Maybe.

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

---

<div class="post-metadata">

**Author:** ![emre](https://forum.sambapos.com/user_avatar/forum.sambapos.com/emre/32/39073_2.png) [@emre](https://forum.sambapos.com/u/emre)\
**Post date:** [July 28, 2014, 7:46pm UTC](https://forum.sambapos.com/t/answered-discount-tag-order-intermittently-functioning/1915/8 "2014-07-28T19:46:13Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![emre](https://forum.sambapos.com/user_avatar/forum.sambapos.com/emre/32/39073_2.png) [@emre](https://forum.sambapos.com/u/emre)\
**Post date:** [July 28, 2014, 8:15pm UTC](https://forum.sambapos.com/t/answered-discount-tag-order-intermittently-functioning/1915/9 "2014-07-28T20:15:48Z")

</div>

Hello @QMcKay. Does it works as expected?

[data45.zip](https://forum.sambapos.com/uploads/default/original/3X/0/8/083210cc9cb7ca245e828ab3a6232100b7500874.zip) (114.1 KB)

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

---

<div class="post-metadata">

**Author:** ![QMcKay](https://forum.sambapos.com/user_avatar/forum.sambapos.com/qmckay/32/27925_2.png) [@QMcKay](https://forum.sambapos.com/u/QMcKay)\
**Post date:** [July 29, 2014, 4:37pm UTC](https://forum.sambapos.com/t/answered-discount-tag-order-intermittently-functioning/1915/10 "2014-07-29T16:37:34Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Jesse](https://forum.sambapos.com/user_avatar/forum.sambapos.com/jesse/32/61493_2.png) [@Jesse](https://forum.sambapos.com/u/Jesse)\
**Post date:** [July 29, 2014, 4:45pm UTC](https://forum.sambapos.com/t/answered-discount-tag-order-intermittently-functioning/1915/11 "2014-07-29T16:45:21Z")

</div>

You can open it via Query analyser and run

---

<div class="post-metadata">

**Author:** ![QMcKay](https://forum.sambapos.com/user_avatar/forum.sambapos.com/qmckay/32/27925_2.png) [@QMcKay](https://forum.sambapos.com/u/QMcKay)\
**Post date:** [July 29, 2014, 5:48pm UTC](https://forum.sambapos.com/t/answered-discount-tag-order-intermittently-functioning/1915/12 "2014-07-29T17:48:34Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Jesse](https://forum.sambapos.com/user_avatar/forum.sambapos.com/jesse/32/61493_2.png) [@Jesse](https://forum.sambapos.com/u/Jesse)\
**Post date:** [July 29, 2014, 6:00pm UTC](https://forum.sambapos.com/t/answered-discount-tag-order-intermittently-functioning/1915/13 "2014-07-29T18:00:54Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Jesse](https://forum.sambapos.com/user_avatar/forum.sambapos.com/jesse/32/61493_2.png) [@Jesse](https://forum.sambapos.com/u/Jesse)\
**Post date:** [July 29, 2014, 6:06pm UTC](https://forum.sambapos.com/t/answered-discount-tag-order-intermittently-functioning/1915/14 "2014-07-29T18:06:34Z")

</div>

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.

> **[Generate Script & Export Data From SQL CE (Compact Edition) 3.5](http://bembengarifin-tech.blogspot.com/2008/08/generate-script-export-data-from-sql-ce.html)**
>
> Several months ago I migrated my family financial and expense information from excel file to SQL CE 3.5 . SQL CE is indeed good enough for d...

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.

---

<div class="post-metadata">

**Author:** ![Jesse](https://forum.sambapos.com/user_avatar/forum.sambapos.com/jesse/32/61493_2.png) [@Jesse](https://forum.sambapos.com/u/Jesse)\
**Post date:** [July 29, 2014, 6:11pm UTC](https://forum.sambapos.com/t/answered-discount-tag-order-intermittently-functioning/1915/15 "2014-07-29T18:11:37Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![emre](https://forum.sambapos.com/user_avatar/forum.sambapos.com/emre/32/39073_2.png) [@emre](https://forum.sambapos.com/u/emre)\
**Post date:** [July 29, 2014, 8:34pm UTC](https://forum.sambapos.com/t/answered-discount-tag-order-intermittently-functioning/1915/16 "2014-07-29T20:34:21Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![QMcKay](https://forum.sambapos.com/user_avatar/forum.sambapos.com/qmckay/32/27925_2.png) [@QMcKay](https://forum.sambapos.com/u/QMcKay)\
**Post date:** [July 30, 2014, 2:58pm UTC](https://forum.sambapos.com/t/answered-discount-tag-order-intermittently-functioning/1915/17 "2014-07-30T14:58:47Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![emre](https://forum.sambapos.com/user_avatar/forum.sambapos.com/emre/32/39073_2.png) [@emre](https://forum.sambapos.com/u/emre)\
**Post date:** [August 3, 2014, 8:45pm UTC](https://forum.sambapos.com/t/answered-discount-tag-order-intermittently-functioning/1915/18 "2014-08-03T20:45:30Z")

</div>

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.

 ![](https://forum.sambapos.com/uploads/default/original/3X/c/5/c551fc4d299e89629a54b7abce68ef4ac670ca6e.jpeg) 

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

 ![](https://forum.sambapos.com/uploads/default/original/3X/5/5/55636c731c89deef61fa916ddd156aa8becfac65.jpeg) 

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.

 ![](https://forum.sambapos.com/uploads/default/original/3X/9/8/98c16d85d0c473b0a182fa0eb9bb8197b5c9b574.jpeg) 

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.

 ![](https://forum.sambapos.com/uploads/default/original/3X/9/a/9a3303dc8d4ca50bba360739b3a97bf6f8bc8ed7.jpeg) 

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.

---

<div class="post-metadata">

**Author:** ![emre](https://forum.sambapos.com/user_avatar/forum.sambapos.com/emre/32/39073_2.png) [@emre](https://forum.sambapos.com/u/emre)\
**Post date:** [August 3, 2014, 8:50pm UTC](https://forum.sambapos.com/t/answered-discount-tag-order-intermittently-functioning/1915/19 "2014-08-03T20:50:58Z")

</div>

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.

 ![](https://forum.sambapos.com/uploads/default/original/3X/6/5/659d33d787502dfde361037ce1ef97af88874ea3.jpeg) 

When I add $2 discount it appears as…

 ![](https://forum.sambapos.com/uploads/default/original/3X/2/3/234dd853633e9a8cd926662996436dab3b9939d5.jpeg)

---

<div class="post-metadata">

**Author:** ![QMcKay](https://forum.sambapos.com/user_avatar/forum.sambapos.com/qmckay/32/27925_2.png) [@QMcKay](https://forum.sambapos.com/u/QMcKay)\
**Post date:** [August 5, 2014, 8:24pm UTC](https://forum.sambapos.com/t/answered-discount-tag-order-intermittently-functioning/1915/20 "2014-08-05T20:24:32Z")

</div>

@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).

 ![](https://forum.sambapos.com/uploads/default/original/3X/5/f/5f785ab914bc562494849ff3ecebcf5bc5a7ae40.png) 

 ![](https://forum.sambapos.com/uploads/default/original/3X/2/e/2ebc6945efe9995f7213f7f5650058d7f993d738.png) 

 ![](https://forum.sambapos.com/uploads/default/original/3X/b/9/b977c995637e1fee93fb96078ae00f8bdf630a93.png) 

![](https://forum.sambapos.com/uploads/default/original/3X/a/a/aa8db9a6177af874246eee12e552d6520e90416d.png)

 ![](https://forum.sambapos.com/uploads/default/original/3X/e/7/e79945503c0fa3ba7e103eec2cf7e9161b0280c1.png) 

 ![](https://forum.sambapos.com/uploads/default/original/3X/e/c/ecce918e08487b4798e5a5c9c920fff8b9628fde.png) 

 ![](https://forum.sambapos.com/uploads/default/original/3X/8/c/8cb0662ae6f2cdb8d5b0addf9e3b012c8b997acb.png) 

![](https://forum.sambapos.com/uploads/default/original/3X/8/e/8eec2d10af65c641c16dd7229e2e89d31830da71.png)

![](https://forum.sambapos.com/uploads/default/original/3X/8/8/8862f36973cfd8612826aaa0c5675b9a31dd2209.png)

![](https://forum.sambapos.com/uploads/default/original/3X/6/6/668b49252dc863314b99ad9d133fb6b5e6cf050a.png)

[Next page](https://forum.sambapos.com/t/answered-discount-tag-order-intermittently-functioning/1915.md?page=2)
