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

Same here I almost stop looking community after 3.30 pm IST as Chuck comes at that time. Hardly we will find any question un answered after that


Abhinay Erra
Giga Sage

Try this



var myHours = current.u_hours_worked;


myHours = parseFloat(myHours).toFixed(2);


kchorny
Tera Guru

You are both awesome and so quick - both methods worked, wish I could set them both as correct.   I'm going to have to go with the fastest again today...