Currency Conversion and Negatives

Home » Currency Conversion and Negatives

There is a strange problem I’ve come across, but easily worked around. I had the need to capture currency values, some of which could be negative. There is a control in the Extension Library, the Dojo Currency Text Box, but I chose to use the Edit Box control with a number converter. But I wanted to force a specific currency, so I added the following in the number converter:

However, whenever I tried a negative number, it threw the error “The field is not a valid number”, triggered by the converter during the Process Validations phase. To confirm there was nothing else causing the problem, I stripped it down to an XPage with the Edit Box bound to a scoped variable and a button doing a partial refresh. I still got the error. Playing around with various settings, I was able to confirm that currencyCode was the problem. Without that property, all was fine. With it, I could enter positive but not negative numbers.

Thankfully, currencySymbol=”£” works fine.

I suspect it’s something to do with the validation of what precedes the number when currencyCode is used, but with a simple workaround, once you know how to fix it, it’s not a problem.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top