Skip to main content
This topic has been closed for replies.

3 replies

anas003
anas003Author
Participant
July 18, 2017

I found the solution

thank you

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

Inspiring
July 18, 2017

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.

try67
Community Expert
Community Expert
July 18, 2017

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

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

anas003
anas003Author
Participant
July 18, 2017

no I have the result on a field

and I want to round it up on another field