Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Trouble getting past arithmetic over/underflow error

Avatar

Level 1

Thanks in advance to anyone that can help out. I've read some forum posts about getting over an error on a LC Designer form for Arithmetic over/underflow that is occurring if a user has not filled out a field yet, so the calculation is trying to divide by zero. I applied some code (javascript below) that has worked for me on all fields I needed it, except for one, and I cannot figure out what I've done wrong.

I'm trying to determine a Loan to Value Ratio. I have been able to successfully calculate the field using the following FormCalc code, written on the calculate event of my field named "Asset1LVR":

Page4.TotalPropertyTable.Row2.PPROwing/Page4.TotalPropertyTable.Row2.PPRValue*100

This is fine and all, but if the user has not yet filled out the "PPRValue" field, then the arithmetic over/underflow error occurs because the value of PPRValue is null.

I have been using a script like this one below on other parts of my form where I was having the same trouble, and the code below works like a charm. For some reason I cannot get this code to work with my Loan to Value Ratio scenario. It is not producing anything in the "Asset1LVR" field at all, so appears to be doing nothing.

This what I am using, written on the calculate event of "Asset1LVR" and Language is set to Javascript:

if ( Page4.TotalPropertyTable.Row2.PPRValue >0) then

     Page4.TotalPropertyTable.Row2.PPROwing / Page4.TotalPropertyTable.Row2.PPRValue * 100

endif

How come the FormCalc version works to calculate, but the JavaScript doesn't?

Any help is much appreciated, thank you.

1 Accepted Solution

Avatar

Correct answer by
Level 1

I managed to come across the answer in another post I missed earlier (REPOST - "Arithmetic Over / Underflow" Error). I've changed my code to what is shown below, and seems to work perfect. Hopefully someone else will find this useful.

// check for divisor having a value and not zero

if

(HasValue(Page4.TotalPropertyTable.Row2.PPRValue) and Page4.TotalPropertyTable.Row2.PPRValue <> 0) then

// perform division

Page4.TotalPropertyTable.Row2.PPROwing

/ Page4.TotalPropertyTable.Row2.PPRValue

* 100

else

// display nothing

""

endif

View solution in original post

1 Reply

Avatar

Correct answer by
Level 1

I managed to come across the answer in another post I missed earlier (REPOST - "Arithmetic Over / Underflow" Error). I've changed my code to what is shown below, and seems to work perfect. Hopefully someone else will find this useful.

// check for divisor having a value and not zero

if

(HasValue(Page4.TotalPropertyTable.Row2.PPRValue) and Page4.TotalPropertyTable.Row2.PPRValue <> 0) then

// perform division

Page4.TotalPropertyTable.Row2.PPROwing

/ Page4.TotalPropertyTable.Row2.PPRValue

* 100

else

// display nothing

""

endif