I have a Percent column, call it [percent] as an example. This Percent column is set to 2 decimal places, so an example value could be 24.24%
When converted to a Decimal, with an App Formula expression DECIMAL( [percent] ), it outputs as 0.2424, which of course is actually 4 decimal places, and is the expected result.
I’m needing to push this value out to an external service, via a Bot with Webhook Task with a Template. If I simply use <<[percent]>> in the Template, I get the text value of “24.24%”. I need the outputted value to be “0.2424”. But if I use <<DECIMAL( [percent] )>>, for some reason it strips the last 2 decimal spots, resulting in just “0.24”.
I’m considering and testing possible workarounds right now, but this feels like a bug to me. What do you think?
EDIT:
As a workaround, simply removing the ‘%’ character has worked in my case here, i.e.:
<<SUBSTITUTE( [percent] , "%" , "" )>>
I thought it would actually produce the value 24.24, but it turns out that it produces 0.2424, which is exactly what I want, strange.
but this feels like a bug to me. What do you think?
I agree!
I assume you are required to use << >> in the webhooks? (not familiar enough with them)
It’s apparent that when using << >>, AppSheet is applying some text function to give the “display” result. This is likely because the most common usage of these brackets are in email and message contexts.
But now you have identified a use case where you need to use those brackets BUT receive the raw data - not the display value.
I would consider this a bug.
The resolution is not straight forward because I could imagine webhook use cases that need that raw value while others need the display value. It would seem for webhook usage, it needs to be left in the hands of the developer to decide which version of the value they need.
It’s apparent that when using << >> , AppSheet is applying some text function to give the “display” result. This is likely because the most common usage of these brackets are in email and message contexts.
Correct.
To get the raw value:
<<"" & [percent]>>
or:
<<CONCATENATE([percent])>>
or by some other means cast the raw value to its raw text equivalent. In fact, I suspect your use of SUBSTITUTE() works because it casts the value to text before doing the substitution. The text value doesn’t actually include the %, so nothing is actually being substituted. For instance, this would probably get the desired value, too:
To get the raw value:> > auto> <<"" & [percent]>>> >
Hah.
[Remove commas in numbers for JSON output](https://community.appsheet.com/t/remove-commas-in-numbers-for-json-output/16115/15) Questions
I had to deal with this today. Adding “”& is equivalent to CONCATENATE(), and much easier to manage in a large template. i.e., change <<[number]>> to <<“”&[number]>>
Same project, same (basic) issue, same solution. Just with a nice long holiday break in the middle…