Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

How do you calculate formatted values

ReluctantProgrammer
Level 2
Level 2

I'm trying to calculate the total of 2 fields which have been formatted using math.floor; I want to calculate the formatted amount of these 2 fields, NOT the rawValue.  How can I do this?

 

example: 

Field 1 rawValue = 700.44                                    Field 1 formatted value = 700.4

Field 2 rawValue = .42                                          Field 2 formatted value = .4

Total rawValue  =  700.86 (rounded 700.9)          Total formatted value = 700.8 ;  this is what I need to do

 

 

1 Accepted Solution
Asutosh_Jena_
Correct answer by
Community Advisor
Community Advisor

Hi @ReluctantProgrammer 

 

Try this:

(Math.round(700.44*10)/10)+(Math.round(0.42*10)/10);

Thanks!  

View solution in original post

4 Replies
Asutosh_Jena_
Correct answer by
Community Advisor
Community Advisor

Hi @ReluctantProgrammer 

 

Try this:

(Math.round(700.44*10)/10)+(Math.round(0.42*10)/10);

Thanks!  

View solution in original post

ReluctantProgrammer
Level 2
Level 2

This formula worked but taking it one step further, I'm trying to leave the field (headwaterExistingMain10) blank unless there is an amount in one of the fields in the formula using this..

 

if (headFtExistingMain10.rawValue==null)
this.rawValue==null
else this.rawValue = (Math.round(hweFtMain10.rawValue*10)/10)+(Math.round(headFtExistingMain10.rawValue*10)/10)

 

....When I Preview the form I get this error...

"Illegal value: cannot assign 'True' to xfa[0].form[0].form1[0]0.page1[0].table1[0].row5[0]0.headwaterExistingMain10[0].#value[0].#float[0]."

 

The kicker is once I click on the 'ok' button in the error box the formula works.  


 

kautuk_sahni
Employee
Employee

@ReluctantProgrammer Thank you for sharing your answer with the AEM community. Keep the great work going. Looking forward to see more contribution from you in future.