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