Client Script FX Currency calculations
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
I have this client script using FX Currency Fields:
Why is this only taking the value left of the "," ?
If I use unitCost of USD;999.00, then it works just fine.
Thanks in advance,
Wade
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
The FX currency field gives you a string like:
USD;999,00
JavaScript’s parseFloat() only understands numbers with a **dot** (`.`) as the decimal separator. When it sees a comma (`999,00`), it stops at `999` and ignores the rest. That’s why `USD;999.00` works fine, but `USD;999,00` doesn’t.
Before you parse the number, replace the comma with a dot:
var unit_price = g_form.getValue('unit_price');
var currencyCode = unit_price.split(';')[0];
var rawValue = unit_price.split(';')[1];
// change comma to dot
rawValue = rawValue.replace(',', '.');
var unitCost = parseFloat(rawValue);
g_form.addErrorMessage('Currency: ' + currencyCode + ', Unit Cost: ' + unitCost);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
8m ago
Hi @Wade Clairmont ,

