The CreatorCon Call for Content is officially open! Get started here.

How to round decimal field value to two decimals in business rule

kchorny
Tera Guru

I'm working on a way to properly bill customers for work done after hours and on holidays.   In my table, I have a field of decimal type - u_hours_worked.   When I look at a record in this table, I see the Hours Worked with 2 decimal places, but the actual value can contain many decimal points.   When I try to display this field in a message, all decimal points are displayed - I want to round to 2 there as well.  

I tried this but it is returning undefined and I've been unable to find another solution.

var myHours = current.u_hours_worked;

myHours = myHours.toFixed(2);

TIA!

Karla

1 ACCEPTED SOLUTION

Chuck Tomasi
Tera Patron

Hi Karla,



You might want to ensure it is a floating point number first.



var myHours = parseFloat(current.u_hours_worked);


myHours = myHours.toFixed(2);


View solution in original post

7 REPLIES 7

Chuck Tomasi
Tera Patron

Hi Karla,



You might want to ensure it is a floating point number first.



var myHours = parseFloat(current.u_hours_worked);


myHours = myHours.toFixed(2);


As soon as I know that we both are working on same thread, I will loose hopes on points


This one was low hanging fruit.


Let me know if that answered your question. If so, please mark it as correct so that others with the same question in the future can find it quickly and that it gets removed from the Unanswered list. Thank you