- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-13-2019 11:56 AM
I have a requirement to show the results of adding two other variables (amount_budgeted + prior_car_costs) into another variable called 'total_cost'. In my research I have seen this accomplished by both catalog script and macro/widget, but have been unable to get it to work for me either way. I thought it may be due to the fact that the values of both 'amount_budgeted' and 'prior_car_costs' already have catalog scripts applied to them to require them to be currency values.
Can anyone advise whether it is better to do this by catalog script or making 'total_cost' a Macro variable and whether the fact that the values are currency makes a difference? I will be happy to provide any relevant information. Thanks!
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-13-2019 12:51 PM
Tony is correct. you do need to parse out the numbers.
but when inserting your returned value into a field you need to have the symbol added to it.
Below is a working client script I used to test this.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var currency1 = parseFloat(g_form.getValue('u_currency').split(';')[1]); //first number
var symbol = g_form.getValue('u_currency').split(';')[0]; //The associated symbol
g_form.addInfoMessage(currency1 + ', ' + symbol);
var total = currency1 + parseFloat(newValue.split(';')[1]); // Current field new value
g_form.addInfoMessage(total);
g_form.setValue('u_currency_total',symbol + ';' + total); // the inserted value
g_form.getValue('u_currency_total'); //see the final insert
//Type appropriate comment here, and begin script below
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-13-2019 12:05 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-13-2019 12:20 PM
If its anything like price it creates a seperate record it references.
Bit of digging it does create a record for currency in the "fx_currency_instance" table.
The ID of that record is a reference to your current record, it also has a refrence to the field you are using.
You may have to edit that existing reference record of the field your currency value is referencing.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-13-2019 12:51 PM
Tony is correct. you do need to parse out the numbers.
but when inserting your returned value into a field you need to have the symbol added to it.
Below is a working client script I used to test this.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var currency1 = parseFloat(g_form.getValue('u_currency').split(';')[1]); //first number
var symbol = g_form.getValue('u_currency').split(';')[0]; //The associated symbol
g_form.addInfoMessage(currency1 + ', ' + symbol);
var total = currency1 + parseFloat(newValue.split(';')[1]); // Current field new value
g_form.addInfoMessage(total);
g_form.setValue('u_currency_total',symbol + ';' + total); // the inserted value
g_form.getValue('u_currency_total'); //see the final insert
//Type appropriate comment here, and begin script below
}