Expand my Community achievements bar.

SOLVED

Round off numbers to the nearest thousand

Avatar

Former Community Member

Is there a way to round off numbers to the nearest thousand in Livecycle Designer ES?

Add topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Level 4

EVENT CALCULATE CALCULATE...

I can try something on formcalc too... though there is no difference between formcalc and javascript in your case

Here you go with formcalc:

Round((SubTotal + OtherCharge1 + OtherCharge2 + OtherCharge3)/1000)*1000

View solution in original post

6 Replies

Avatar

Level 4

Here you go:

Javascript:

this.rawValue = Math.round(this.rawValue/1000)
this.rawValue = this.rawValue * 1000

I'd suggest you the exit or the pre-print/send event.

if you want to round down (even if the last three digits are >=500):

this.rawValue = Math.floor(this.rawValue/1000)

this.rawValue = this.rawValue * 1000

Avatar

Former Community Member

I am using FormCalc and I already have a calculate script as shown below

form1.#subform[0].Body.GrandTotal::calculate - (FormCalc, client)

SubTotal

+ OtherCharge1 + OtherCharge2 + OtherCharge3

I wrote the code below in Exit and it still shows the original value. (Changed to Javascript)

this.rawValue = Math.round(this.rawValue/1000)
this.rawValue = this.rawValue * 1000

Also tried on PrePrint, still doesn't work. Can't see 'Send' event.

Thanks.

T

Avatar

Level 4

this.rawValue = SubTotal.rawValue + OtherCharge1.rawValue + OtherCharge2.rawValue + OtherCharge3.rawValue;

this.rawValue = Math.round(this.rawValue/1000);
this.rawValue = this.rawValue * 1000;

Exit it Javascript ;D

equivalent:

this.rawValue = SubTotal.rawValue + OtherCharge1.rawValue + OtherCharge2.rawValue + OtherCharge3.rawValue;

this.rawValue = Math.round(this.rawValue/1000);
this.rawValue = this.rawValue * 1000;


There's a round function in formcalc too... but forgot it... (and the semicolons ;( not my day today...)

Though... this one should work... javascript is in some functions maybe not as "fast" as formcalc... but 4 fields will be done in no time ;D

If you want it in a 1 line thing:

this.rawValue = Math.round ((SubTotal.rawValue + OtherCharge1.rawValue + OtherCharge2.rawValue + OtherCharge3.rawValue)/1000)*1000

Should work too ^^

Avatar

Former Community Member

Thank you so much, btw will it be the same for FormCalc?

I am using FormCalc.

Tamilgodi

Avatar

Correct answer by
Level 4

EVENT CALCULATE CALCULATE...

I can try something on formcalc too... though there is no difference between formcalc and javascript in your case

Here you go with formcalc:

Round((SubTotal + OtherCharge1 + OtherCharge2 + OtherCharge3)/1000)*1000

Avatar

Former Community Member

Thanks! It works

T