I want to add a certain number of zero to the left of an integer number and save it to an Integer rule input..I was using text(value,"0000") this function which gave me exact format but when I save that to an Integer variable , all zeros had been removed.
Id type is Number(Integer)for ref:
{ a!textField( label: "Text", labelPosition: "ABOVE", value: text(tostring(ri!Id), "0000"), saveInto: ri!Id, refreshAfter: "UNFOCUS", validations: {} ), a!buttonArrayLayout( buttons: { a!buttonWidget(label: "save", style: "OUTLINE") }, align: "START", marginBelow: "NONE" )}
Discussion posts and replies are publicly visible
Hi prashamas6791 , What is your actual requirement? If you're trying to concat four zeros (0000) before the ID, why are you using text() under the value? Additionally, it will not accept a number like 01223; it will only accept 1223, and the leading zero will be removed. When we try to pass the zero as a value to the rule input, it will accept it. Therefore, try using text or any other type by handling it in the submit/save button or through a local variable. However, it will only accept one zero as a prefix, even if you concatenate four zeros (0000).Please let me know if you need any additional help here or if you get the solution.
Thanks for your suggestiongayatria0439 My requirement is save "00234" this kind of format into an integer field , there is an related record field(integer)where I should saving the value ... in case of concat the leading zeros are previously visible to the field and in that case also all zeros are removed while saving....so can you please suggest ...is that possible to save the said format into an integer field.
Hello prashamas6791 ,I think it is not possible because if it is an integer field, then it won't accept this format because it will remove all the zeros before the ID.
If you want to display leading zeros, I would suggest using a textfield. You can use a regex function to validate that all characters are numbers. Otherwise, tointeger on the onSave will just strip the non-integer values.
prashamas6791 said:.is that possible to save the said format into an integer field.
It's not possible , Just like others suggested the only two possibilities are
1. Changing the data type of the field to string
2. On interface level show it in a text field by adding the zeros .
Got it, thank you Mathieu Drouin
Appreciate the suggestion , thank you venkat Avuluri
To clarify, integer (the data type) does not understand or care about "leading zeroes". "0001" is not a distinct integer from "1", both have a value of "1" (stored deeper in the system as the binary representation fo the number "1" moreover).
What you're asking for here is display formatting, for which (as others have mentioned) you'd use text and various rules/functions to format its displayed value, and/or you could store a literal representation of the displayed format you're after into a text field.
But what you need to understand most is that these are completely different things - otherwise you're gonna have a hard time with coding anything in Appian.
Thank you Mike Schmitt