Adding values gives error - Forum - Rollbase - Progress Community

Adding values gives error

 Forum

Adding values gives error

  • 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... 

  • 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;

  • 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();

  • Are fields on the related record Currency Fields?

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

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

  • 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

  • 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.

  • 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.