Hi All,
I need to show and store 7 digits after decimal and before decimal its 'n' number and the data type is number(decimal) how I can do that?
Thanks in advance.
Discussion posts and replies are publicly visible
I am not sure what you are looking for.
https://docs.appian.com/suite/help/23.3/Appian_Data_Types.html#number-(decimal)
Do you want to allow the user to enter any number but always have it be presented in the User Interface always with the full 7 digits after the decimal point? Examples:
Enter: 123 -> presented as 123.0000000
Enter: 12.12345678 -> presented as 12.1234568
Enter: .2 -> presented as 0.2000000
Is that the requirement?
text(ri!decimal,"0.0000000")
You can use this code to show a decimal number as text with the required format
Thanx For the reply Stewart
If user enter 12345.1234567899 then in UI it should show and store only 1234.1234567
if enter 123456.12 it will show as it is, only after 7 digits it will not show
Thanx for the reply
but it will return text right, I want number decimal to be return will it possible?
todecimal(text(ri!decimal, "0.0000000"))
i think it will work for your requirement
please check
It is taking only this digits
Appian uses double precision floating-point decimal numbers to store your decimal numeric values. Always and in all places!
When Appian displays that value to you, on screen, in a text form, it rounds it to two decimals by default. To change that, you can use the text() function which then returns text.
If you want to modify the underlying data value, use round().
Ok, so you need to separate in your mind how the data is held in memory (this will be using a Decimal data type) from how you want it captured/presented to the user. This code snippet might help:
a!textField( label: "My Decimal", value: fixed(ri!myDecimal,7), saveInto: { a!save( ri!myDecimal, if( fn!regexmatch( "^\d*(\.\d+)?$", save!value, "i" ), save!value, 0 ) ), } ),
The ri!myDecimal is of type Number(Decimal) but as you can see I'm using a Text Field to allow the user to enter their value.
Where the text entered conforms to the pattern of a Decimal (that's what the RegEx expression is checking) then it is presented as a Decimal with 7 digits after the decimal point (that's what the fixed() function is doing)
Because the input field is text you need to handle the fact that a user might enter non-decimal representations e.g. "ABC". That's what the second part of the if() statement is doing.
Hope this helps.