Skip to main content
Gary8178
Participant
February 12, 2019
Question

On Adobe XI Pro form tool how do I write a calculation such as excel formula =IFERROR(G14/C14,"")?

  • February 12, 2019
  • 5 replies
  • 1278 views

On Adobe XI Pro form tool how do I write a calculation such as excel formula =IFERROR(G14/C14,"")? When the form is blank the cell is not acting correctly with a return of zero ($0.00). Current simple field notation is PV1/OP with the return in a %.

This topic has been closed for replies.

5 replies

Legend
February 12, 2019

The script would be written by a programmer. Would you like resources to learn how to program JavaScript?

Gary8178
Gary8178Author
Participant
February 12, 2019

Is there a good source of information on how to program javascript?

Legend
February 12, 2019

I think you're right. Could go further with

(A+0) == 0 ? 0 : (B+0) / (A+0) )

but it really isn't "simplified". Crucially, I think it would leave beginners more confused, not less...

Legend
February 12, 2019

No, I'm saying it IS valid. I tried it in Acrobat X... like all simplified field notation, it compiles directly into JavaScript, and this looks valid to me.

try67
Community Expert
Community Expert
February 12, 2019

Oh really? Wow... I'll try it myself.

try67
Community Expert
Community Expert
February 12, 2019

It does work, but the results are not really desired, I think... If both fields are empty the outcome is "NaN", and if A is empty but B is not (and not 0) the result is Infinity. I still think a script is the best way of doing it.

try67
Community Expert
Community Expert
February 12, 2019

You can either check if the divisor is zero (or empty) first, or check if the result of the operation equals "Infinity" (no quotes). If that's the case, you know it was the result of division by zero, and then apply another value to it.

Keep in mind, though, that a percentage field can never be empty. Its default value is "0%", which is not always the correct result...

Legend
February 12, 2019

Did anyone know that this is valid in simplified field notation:

A == 0 ? 0 : B / A

I was susprised, and cannot find a specification...

try67
Community Expert
Community Expert
February 12, 2019

No, it's not. You need to use a script.

Legend
February 12, 2019

Acrobat allows a programmer to adds JavaScript code to do calculation and verification.  To handle the specific case here you would use getField to read the value of C14, and make sure it isn’t zero before dividing by it.