The code you have posted looks to have incorrect single quotes. It could be just a copy-paste issue. But still, if you could check. This is how it looks where I have used it: formatCurrency('$', '.', ',', 0)
I haven’t been able to update my Wappler yet. It downloads really-really-really slowly due to some CDN/ISP issues. So can’t test on my system to confirm if this is an issue on the project where I am using this.
found a bug in browser after putting code back in and running again
Formatter formatCurrency in expression [sc_UserJobSummary.data.q_UserJob_sel[0].balancepaid.formatCurrency(’$’, ‘.’, ‘,’, 2)] doesn’t exist for type string
That’s exactly the error I was assuming to be present in the console.
Just use balancepaid.toNumber().format....
You can find the to number formatter in action picker UI.
in the DB its a decimal(10,2). When I set it up to format I selected number (as its only then that you get the option to format it to a currency). So it should be a number format shouldnt it?
thanks, the toNumber worked, but still like to know why it didn’t work with native wappler as its a decimal in the DB and its set to number in wappler to format as currency.
Thats a mystery since day 1. Never bothered to make a post or ask to be honest. Have seen it many times myself. Maybe something to do with supporting multiple types of SQL Servers.
Maybe @Teodor can shed some light on it.
It is indeed mysterious. I copied a file from an old site to a new one recently and just noticed the price field, with currency formatting applied, was empty. I compared this with the site I had copied it from and couldn’t see any obvious difference; the versions of dmxFormatter.js were the same etc. Once I added toNumber(), all was well - but this wasn’t needed before, in the original site which still works fine. The two files are identical.
The toNumber formatter requires a number as input, so probably the value used in the new site was not a number but a string. Problem often is the database driver, in some cases it returns a string for number fields and that is something you would not expect. It depends on different combinations, for example an BIGINT often converted to string in PHP since it doesn’t support 64 bit. And so there are more cases of numbers being returned as strings by the database.
Thanks Patrick. In this case, the database and server, and pretty much everything else is the same. The database for the second site is a copy of the first and the field in question is defined as an integer. I usually would use toNumber straightaway in such cases, but as this was file was copy/pasted from another site, I was puzzled that it didn’t work. Anyway, there’s a simple solution to the problem.