Hi all
I am following Appian standard in using a text field on a form with which to populate a decimal field in my rule input.
Appian standard behavior for a decimal field is that if a comma symbol is used to indicate a decimal place, the symbol is automatically removed and the value is then displayed with no separation.
Example:
The user enters 650,52
On refresh, the comma disappears and the value saved in the rule input is now 65052
If one uses the period symbol, the value is displayed correctly, thus 650.52, and the value is saved correctly into the rule input
We cannot assume that the target group of users will understand the distinction between the symbols, so we need to put in some sort of validation in order to avoid the issue.
I have tried using the cleanwith() function, but am unable to make it work.
I would like to be able to do one of the following (in order of preference):
Any help will be greatly appreciated!
Discussion posts and replies are publicly visible
Something along these lines? Does the job but probably could use some tinkering.
a!textField( label: "Your Decimal", saveInto: a!save(target: ri!decimal, value: todecimal(replace(save!value,find(",",save!value),1,"."))), value: ri!decimal, )
Out of interest, what Appian standard of using a text field instead of a decimal field are you referring to?
Hi, Marcel
HALLELUJAH!
Thank you very much, that does the job.
The Appian standard I am referring to comes from the usage considerations section on this page:
https://docs.appian.com/suite/help/22.1/Floating_Point_Component.html
which refers to using a text field to apply special formatting such as currency.
Regards
Stephen
On what Marcel suggested, if you try to insert a number having 2 commas or having a comma and a dot as separators then it's not working properly. So that needs some improvements on what number formats can be accepted. Also, because the component is a textField, it can accept letters also and not only numbers. So you have to use the cleanwith() function to allow only numbers, periods, and comma characters to be inserted.
Also, an OOT, are you suggesting your answer as a correct answer to your own question? That's bizarre man LOL
For this reason (the use case with multiple commas) it may be better to use your #3 suggestion (validation) instead of replacing the commas with periods because you're less likely to encounter weird edge cases like this.
Yes, I believe the same. It's more safe and easy to build as he will avoid many different scenarios that need to be covered during the number typing.