Hello Everyone,
I am using text() or any function in type!{urn:com:appian:types}Test'(). But it seems not working. Can anyone suggest how I can do this?
Thanks
Discussion posts and replies are publicly visible
Quantity is of integer type so you cannot have decimal value there, please change the data type
I Would recommend to change dataType of quantity to text or decimal based on your requirement.
I think that the issue here is that fixed() and text() return a string, but not a number. If you want to DISPLAY the final sum to the user in a specific format, do that at the place where you display it, but not when calculating it.
it's unclear to me why there are so many manipulations being done on the number.
sum and round should be sufficient to give you a decimal which you can then format anyway you want for presentation using text/fixed or even a!currency(). https://docs.appian.com/suite/help/24.2/recipe-define-a-simple-currency-component.html
And if you need to store that amount, you will need a decimal field in your Test() Data Type.
If you're trying to convert a number to a string, you simply need "toString()". text() does something altogether separate.
Now if you're really needing to take a decimal and make sure your displayed amount is that decimal with a constant number of places, there are various rules available (check out the Appian Functions documentation for the master list, as always), but one of my favorites is "fixed()", which you feed a number and a "number of places" value and it outputs the decimal with that many places (returning a rendered text value).
Quantity field is decimal type in a database table. I have updated the xsd file as well. But it still not woking.
After changing datatype from Decimal to Varchar - It worked. However, still wondering if this is good way of returning decimal value with Varchar instead of Decimal. Really appreciate your feedback how better this could handle and where potentially the issue lies.
Would you mind showing us the .xsd file?
I've done some tests on my end putting text/fixed into a decimal field and can't reproduce the issue.
I personally wouldn't recommend storing the amount as a varchar. Probably best to find the root cause of this issue.
This is what I am asking. What should I do? Please see below code I am using to achieve.
a!forEach( items: ri!empdetails, expression: 'type!{urn:com:appian:types:TPR}TPR_TEST'( name: fv!item.name, joinDate: fv!item.date, quantity: if( rule!GLB_isBlank( index(fv!item, "amount", {}) ), {}, fn!text( fixed( abs( sum( index(fv!item, "amount", {}), ) ), 2, ), "00.00" ) ), account: fv!item.account, ) )
As I said, I have changed datatype from Decimal to Varchar for quantity field. It would be appreciated If I get assistance on this.