The solution is to either default the field values so that the calculation completes without error, or use a script for the calculation that includes checks on the input values.
Could you post a screenshot of the warning window?
Another solution is to not use an automatic calculation and use a button that the user will press to calculate.
Thank you all for your ideas,
Attached is the link to the pdf that I am creating with the table and the form with all its fields.
As you can see the option of assigning default values to all the fields involved in the final calculation I have already done so, however the warning message continues to appear.
In order to understand the concept a bit better, I commented that the table calculates the loss of load in a natural gas pipeline; the nodes represent specific points of the installation where an equipment is installed, for example.
The form is for general use, in various conditions, for which the user may need to fill only the first line (one node) or can use all of them.
1 person found this helpful
There's a mathematical error in your code. You're in effect performing a division by zero, even if it doesn't look like it.
The error comes from this part of the formula (I'm taking "Dp A" as an example):
Math.pow(this.getField("D A").value, -4.82)
This is identical to 1/(x^4.82), x being the value of the field. But when the field is empty, this value is zero, and the result is:
1/(0^4.82) = 1/0
Which is illegal.
The solution is to add an if-condition that only performs this calculation if "D A" is not empty or zero, like this:
if (Number(this.getField("D A").valueAsString)==0) event.value = ""; else event.value = (25078 * 0.6 * (this.getField("Le A").value) * (Math.pow(this.getField("Q A").value, 1.82)) * (Math.pow(this.getField("D A").value, -4.82))) * (this.getField("FSA").value);