Skip to main content
This topic is closed to new replies. Start a new post to keep the conversation going.

4 replies

anas003
anas003Author
Participant
Jul 18, 2017 11:24 PM UTC

I found the solution

thank you

event.value = Math.ceil(this.getField("Field1").value);

Translate
Inspiring
Jul 18, 2017 11:02 PM UTC

If the value were 5.4 would you want that value rounded up to the next integer?

Setting the field's format "Number" and setting the desired number of decimal places will cause the displayed result to be rounded up but will not change the value of the field.

To change the value of field one must use a user written rounding routine. Most likely one would use this in a Custom JavaScript calculation.

One can use the util.printf() method to round a calculation to a desired number of decimal places.

// round the focused field to no decimal places;

var nDec = 0; // variable to use for the number of decimal places to round to. in this case none or zero;

event.value = Number(util.printf("%,101." + nDec + "f", event.value);

D.P. Story has a much more robust function that can round to whole numbers or decimals with rounding.

Translate
try67
Community Expert
Community Expert
Jul 18, 2017 10:07 PM UTC

Add this code as the field's custom calculation script:

if (event.value) event.value = Math.ceil(event.value);

Translate
anas003
anas003Author
Participant
Jul 18, 2017 10:12 PM UTC

no I have the result on a field

and I want to round it up on another field

Translate