Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Help: Divide by Zero Errors


Level 2
Hi, can someone please advise me on how to avoid script failure alerts (like the one below), which are generated because certain calculations are being performed before any positive value has yet been set in a numeric field?

Here is an example of the calculation:

--- form1.SF_CalculationTable.acview[0]::calculate - (FormCalc, client) --

(ac[0] / tr[0]) * 100

Error example:

Script failed (language is formcalc; context is


script=(ac[0] / tr[0]) * 100

Error: arithmetic over/underflow.

update: it appears these erros are "divide by zero" errors.

So my questions are,

(1) would I put any javascript (to override the zeros) on the "validate" event or the "calculate" event, and on which of the three fields in question, acview[0] (the result), tr[0] (the denominator) or ac[0] (the numerator). and...

(2) What might that javascript look like?


1 Reply


Level 2

Your error message indicates your script is being executed as FormCalc, not JavaScript.

If you're using FormCalc try using an If statment to test for zero/null.

if (tr>0) then (ac/tr)*100 endif