Hi All,
I am having one use case where I want to store decimal value.
But when I enter amount like 10.10 in decimal type field , it is returning 10.1 when I click outside because it is decimal type value.
I want same value as user entered. e.g If I entered 10.10, value should remain same 10.10 not 10.1.
Please leave your suggestion to achieve this.
Thanks,
Vinod Tate
Discussion posts and replies are publicly visible
I know that it's an old discussion but the answer here was not as good as I expected.
I have one CDT that retains currency values like you said: 270,000.83 and sometimes it's 270.000,83 or even 270000,83.
Appian acknowledges decimal as \d.\d{2} (270000.83 can be converted as decimal, for example).
So in our case, we needed to convert the possible values to real decimals and to be possible sum these values, for example.
When we managed to convert the Text do decimal, we noticed that the decimal was truncated at the end.
The text 270.000,83 was convert to 270000.8 --' and if we convert it back to Text, it remains truncated.
To manage that, in our case, what worked is create an Expression Rule to convert to decimal, make any sum or mathematical expressions and, finally, convert to currency (https://docs.appian.com/suite/help/22.4/fnc_text_currency.html). Doing that, the two digits after ',' are back! \o/
Here are my ER to transform Text to Decimal (String_To_Decimal), if anyone finds it usefull (rule input: valorStr):
a!localVariables( local!valorTeste: ri!valorStr, local!testRegex1: fn!regexmatch("\,\d{2}(?!\d)", local!valorTeste), local!resRegex1: if( local!testRegex1, with( local!matchMarker: regexinsertmatchmarkers( pattern: "\,\d{2}(?!\d)", searchString: local!valorTeste, leftMarker: "a", rightMarker: null, FirstMatchOnly: true ), fn!regexreplaceall( pattern: "a\,", searchString: local!matchMarker, replacementString: "." ) ), local!valorTeste ), local!testRegex2: fn!regexmatch("\.\d{3}(?!\d)", local!resRegex1), local!resRegex2: if( local!testRegex2, with( local!matchMarker: regexinsertmatchmarkers( pattern: "\.\d{3}(?!\d)", searchString: local!resRegex1, leftMarker: "a", rightMarker: null, FirstMatchOnly: false ), fn!regexreplaceall( pattern: "a\.", searchString: local!matchMarker, replacementString: null ) ), local!resRegex1 ), local!testRegex3: fn!regexmatch("\,\d{3}(?!\d)", local!resRegex2), local!resRegex3: if( local!testRegex3, with( local!matchMarker: regexinsertmatchmarkers( pattern: "\,\d{3}(?!\d)", searchString: local!resRegex2, leftMarker: "a", rightMarker: null, FirstMatchOnly: false ), fn!regexreplaceall( pattern: "a\,", searchString: local!matchMarker, replacementString: null ) ), local!resRegex2 ), local!decimal: todecimal(local!resRegex3), /*currency(local!decimal)*/ local!decimal)