- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-03-2015 11:20 AM
I'm creating a finance application within SN, and I'm having trouble adding currency fields together and getting them to return a value into another currency field.
I haven't had too much luck in figuring out why my code doesn't work; my researched showed that there are three "elements" in the currency field that all have to be addressed when you're setting a value, but I haven't figured that out either.
To simplify my example, say I was to add a field called "Year One" and "Year Two" together and place it into a field called "Total". All of these fields are currency field all using USD. Here is how I'm currently adding them.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue == '') {
return;
}
//get values in all of the existing currency fields
var two = g_form.getDecimalValue('u_year_two');
var one = g_form.getDecimalValue('u_year_one');
//parse float method
var total = (parseFloat(one) + parseFloat(two)).toFixed(2);
g_form.setValue('u_total', total);
}
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-03-2015 01:17 PM
This should address your query.
Setting Currency Field values via client-side script
I hope this helps
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-03-2015 11:31 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-03-2015 11:55 AM
The problem is that I need to do these calculations in a client script - so I can't use current.price

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-03-2015 01:17 PM
This should address your query.
Setting Currency Field values via client-side script
I hope this helps
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-25-2018 09:52 AM
Hi All,
Could you please let me know how do I print the negative value in currency field? like $-20, $-400,$-5000 etc. Because on log message its printing with - but on field it print $20,$400,$5000 etc...
Quick reply much appreciated