Not repeating yet, I am still trying to build a card with dynamic data in it then later it will hopefully repeat. As I provided the code from Wappler I was trying to get it to be currency from a number in the table I queried. Also would be good to know how to just format with commas and no $, but either way this thing is not working so far for no apparent reason.
And then this from GPT: The error message you're seeing:
Method "formatCurrency" not found in expression: serverconnect1.data.propertiesQuery[0].valuation.formatCurrency('$', '.', ',', 2)
means that Wappler is trying to call a method (formatCurrency
) that does not exist or is not recognized in the current context. It seems that the formatter you're trying to use is either not supported or hasn't been properly registered in your project.
What This Means:
formatCurrency
is not a built-in method in Wappler or JavaScript.
- Wappler might be trying to invoke it, but it's not defined or available within the data binding or Wappler's formatters.
- This error indicates that Wappler's formatter system doesn't have access to a method called
formatCurrency
.
Solutions:
1. Use .formatNumber()
Instead:
If you're looking to format a number with commas (as discussed earlier), use .formatNumber()
instead of .formatCurrency()
.
In your Wappler binding, it should look like this:
<p class="card-text" dmx-text="serverconnect1.data.propertiesQuery[0].valuation.formatNumber('0,0')"></p>
This will format the valuation
with commas, e.g., 350000
becomes 350,000
.
2. Custom Currency Formatting (JavaScript):
If you want to apply a currency format (with a dollar sign and decimals), you can implement custom formatting in JavaScript, as discussed previously.
Example:
var formattedValuation = new Intl.NumberFormat('en-US', {
style: 'currency',
currency: 'USD',
minimumFractionDigits: 2,
}).format(valuation);
This would format 350000
as $350,000.00
using JavaScript, and you can apply this to your element as needed.
Why the Error Happens:
- Wappler’s formatter system includes methods like
formatNumber()
, but there is no built-in formatCurrency()
method, so it throws an error when it tries to execute it.
How to Fix:
- Replace the erroneous
.formatCurrency()
method with .formatNumber()
in Wappler.
- If you're looking for more advanced currency formatting, stick to using JavaScript formatting like
Intl.NumberFormat
.
Let me know if this clarifies the error and helps you solve the issue!