# Expressions for Discount

**URL:** <https://forum.sambapos.com/t/expressions-for-discount/8934>\
**Category:** V5 Question\
**Created:** [January 11, 2016, 8:02am UTC](https://forum.sambapos.com/t/expressions-for-discount/8934 "2016-01-11T08:02:24Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![luisvarca](https://forum.sambapos.com/letter_avatar_proxy/v4/letter/l/ecb155/32.png) [@luisvarca](https://forum.sambapos.com/u/luisvarca)\
**Post date:** [January 11, 2016, 8:02am UTC](https://forum.sambapos.com/t/expressions-for-discount/8934/1 "2016-01-11T08:02:24Z")

</div>

Hello Everyone,

I am working on a discount button which allows only 1-30 percent discount. In the tutorial for the discount button I see an expression which is for 1-10%, it is: [?Discount Rate:[1-9]|10 It]

This works nicely for 1-10 however I am unsure how to accept 1-30%. Can anybody please help with this.

Thank you

---

<div class="post-metadata">

**Author:** ![sukasem](https://forum.sambapos.com/letter_avatar_proxy/v4/letter/s/b38774/32.png) [@sukasem](https://forum.sambapos.com/u/sukasem)\
**Post date:** [January 11, 2016, 5:17pm UTC](https://forum.sambapos.com/t/expressions-for-discount/8934/2 "2016-01-11T17:17:17Z")

</div>

Try [1-9] | [1-2][0-9] | 30

---

<div class="post-metadata">

**Author:** ![luisvarca](https://forum.sambapos.com/letter_avatar_proxy/v4/letter/l/ecb155/32.png) [@luisvarca](https://forum.sambapos.com/u/luisvarca)\
**Post date:** [January 11, 2016, 5:45pm UTC](https://forum.sambapos.com/t/expressions-for-discount/8934/3 "2016-01-11T17:45:14Z")

</div>

Does not work when I do: [?Discount Rate:[1-9] | [1-2][0-9] | 30]

It does not let me enter double digits.

---

<div class="post-metadata">

**Author:** ![JTRTech](https://forum.sambapos.com/user_avatar/forum.sambapos.com/jtrtech/32/21270_2.png) [@JTRTech](https://forum.sambapos.com/u/JTRTech)\
**Post date:** [January 11, 2016, 5:50pm UTC](https://forum.sambapos.com/t/expressions-for-discount/8934/4 "2016-01-11T17:50:32Z")

</div>

I would start here;

> [@Custom Keyboard Codes](http://forum.sambapos.com/t/custom-keyboard-codes/3006):
>
> As of v4.1.61 we can create Custom Keyboards to use with [?prompt] notation, and a Custom Keyboard Widget is available for Entity Screens. For [?prompt] notation, the syntax is: [?\<prompt\>;\<mask\>;\<default value\>;\<flags\>;\<keycodes\>] \<prompt\> is the question or prompt to display \<mask\> is a regular expression to define what type of characters (and how many) are allowed \<default value\> allows for a common value to be pre-entered \<flags\> lets you define the keyboard type and which buttons …

Although doesn’t mention setting a maximum.  
Perhaps it was setting default value of 10 and the mask only allowing single digit…  
[?Prompt] expression offers these options `[?<prompt>;<mask>;<default value>;<flags>;<keycodes>]`

If you made it a two stage flow with the prompt in an execute automation command in value fields you could define all sorts of prompts should a value be entered wrong using constraints on the command value lide [:CommandValue] \> 30 on an ask question prompt saying discount only possible up to 30% and then your action to apply discount would have constraint of [:CommandValue] \< 30

---

<div class="post-metadata">

**Author:** ![sukasem](https://forum.sambapos.com/letter_avatar_proxy/v4/letter/s/b38774/32.png) [@sukasem](https://forum.sambapos.com/u/sukasem)\
**Post date:** [January 11, 2016, 6:17pm UTC](https://forum.sambapos.com/t/expressions-for-discount/8934/5 "2016-01-11T18:17:44Z")

</div>

Try add ? After [1-9]?

Update: I got it backword. It has to have double digits first.

`[1-2][0-9] | 30 | [1-9]`

---

<div class="post-metadata">

**Author:** ![luisvarca](https://forum.sambapos.com/letter_avatar_proxy/v4/letter/l/ecb155/32.png) [@luisvarca](https://forum.sambapos.com/u/luisvarca)\
**Post date:** [January 12, 2016, 3:16am UTC](https://forum.sambapos.com/t/expressions-for-discount/8934/6 "2016-01-12T03:16:40Z")

</div>

> [@sukasem](#):
>
> [1-2][0-9] | 30 | [1-9]

When I do this I am able to enter double digit discounts but not 0-9. Also not 30, only up to 29.

I need to be able to enter 1-30 single or double digits. Any help - really appreciate it,

---

<div class="post-metadata">

**Author:** ![sukasem](https://forum.sambapos.com/letter_avatar_proxy/v4/letter/s/b38774/32.png) [@sukasem](https://forum.sambapos.com/u/sukasem)\
**Post date:** [January 12, 2016, 3:43am UTC](https://forum.sambapos.com/t/expressions-for-discount/8934/7 "2016-01-12T03:43:43Z")

</div>

> [@sukasem](#):
>
> [1-2][0-9] | 30 | [1-9]

LOL, Sorry, try remove space 😉  
`[1-2][0-9]|30|[1-9]`

UPDATE: Just test it

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