Adding values gives error

Posted by mysteryminds on 14-Jan-2016 09:06

Hi RB Gurus

Kindly let me know how can i add  these values 

var num = {!R168872065.Other_iB#value} + {!R168872065.OCB#value};
var n = num.toFixed(2); return n;

It returns this 

var num =
$ 4,700.00
 + 
$ 350.00
;
	var n = num.toFixed(2); return n;
}


But the answer must be  $ 5,050.00

I think the issue is coming due to the fact the "$" is getting adding to the numeric before, and it must be removed to add the values... 

All Replies

Posted by jsniemi79 on 14-Jan-2016 09:19

If the formatting is getting in your way, try converting them to decimal fields and see if that helps.

Something like this.

var num = parseFloat({!R168872065.Other_iB#value}) + parseFloat({!R168872065.OCB#value});

rbv_api.formatCurrency(number, currSymbol, decPlaces, decSeparator, thSeparator)

var n = num.toFixed(2);

n = rbv_api.formatCurrency(n);

return n;

Posted by mysteryminds on 14-Jan-2016 09:28

var num = parseFloat({!R168872065.Borrower_s_Total_Income#value}) + parseFloat({!R168872065.Co_Borrower_s_Total_Income#value});
rbv_api.formatCurrency(number, currSymbol, decPlaces, decSeparator, thSeparator);
var n = num.toFixed(2);
n = rbv_api.formatCurrency(n);
return n;




Error missing ) after argument list (line #5) in formula: function wrapper() { var num = parseFloat( $ 4,700.00 ) + parseFloat( $ 350.00 ); rbv_api.formatCurrency(number, currSymbol, decPlaces, decSeparator, thSeparator); var n = num.toFixed(2); n = rbv_api.formatCurrency(n); return n; } wrapper();

i.formatCurrency(number, currSymbol, decPlaces, decSeparator, thSeparator);

var n = num.toFixed(2);

n = rbv_api.formatCurrency(n);

return n;

}

wrapper();

Posted by jsniemi79 on 14-Jan-2016 09:42

Are fields on the related record Currency Fields?

Posted by mysteryminds on 14-Jan-2016 09:48

Also you GURUS some one can suggest me a way to remove"$" sign before adding  the 2 numbers... that will solve my issue

Posted by Karthikeyan Bhaskaran on 14-Jan-2016 10:29

A  string.replace(/[^0-9\.]+/g, "") followed by the parseFloat should work. Will check how this goes for the [tag:value] and get back.

Posted by mysteryminds on 14-Jan-2016 11:21

it doesnt work so far... what I don't understand is that  the same field which has been created in OBJECT C

{!#LOOP_BEGIN.R167240597#220306428}

{!R167240597.Borr_Total_income}

{!#LOOP_END.R167240597}

displays 4500.00

But when I start to reference the same field in other object it displays as $ 4,500.00

Posted by murali on 15-Jan-2016 02:56

Are the fields  of Type 'Currency' ?  Currency Fields return  numerical values (unformatted decimal values eg : 12345.67) on API calls ( irrespective of whether field is on self or related record). If they are not currency fields, you should use some javascript formatting. If they are currency fields, you have hit a bug that we should fix.

Posted by Karthikeyan Bhaskaran on 28-Mar-2016 01:37

Hi, Assuming a currency field, I was able to get the values working without any effort (on 4.0.6.3). If this requirement is still "open", can you please check if it's working for you? In my testing, I tested a currency field in Obj1, and from a related Obj2, looked up an Obj1 record. This in turn picks its Currency field value, to which I add a 5.00 using a Formula field. This works fine. If this is still a use case you are pursuing, can you get back if the original problem has gone away? For the formula field, my Formula is just this: var num1 = parseFloat({!R31805.testCurr#value}) 5.00; //testCurr is a Currency field, and the return type for the Formula is also Currency. return num1; Thanks.

This thread is closed