Copy link to clipboard
Copied
My original equation is 20250/(Downflow+Inflow)
I want the calculated field to be blank if the inflow field stays 0.
This is the code I've been playing with, but I just can't get it to take.
event.value = (20250/(getField("DownflowCFM").value + getField("InflowCFM").value));
if(getField("InflowCFM").valueAsString === 0)) event.value = "";
Can someone help, please?
Add this as the custom validation script:
if (this.getField("InflowCFM").valueAsString == "0") event.value = "";
Copy link to clipboard
Copied
What results are you getting with your script?
Is that result correct?
In most computer languages the "if" statement has an optional "else" statement. JavaScript is not an exception.
Copy link to clipboard
Copied
You need to move the if-statement before the other line, and add an else at the start of that line.
Also, your condition doesn't cover the situation when the sum of both fields is zero. In that case you'll be dividing by zero, which is not an allowed operation.
Copy link to clipboard
Copied
The downflow will always have a value greater than 0, so it would never divide by zero.
The result is still there instead of blank when the inflow is 0. I want the field to be blank (or hidden) if the inflow is 0.
Copy link to clipboard
Copied
Ok. So there's the real issue. The calculations are working fine. I just would like it to be hidden if the inflow is 0. Sorry for the confusion.
Copy link to clipboard
Copied
I got rid of all the garbage and entered the simple equation into the Simplified field notation:
20250/((DownflowCFM)+(InflowCFM))
Can I hide the result if the inflow is 0?
Copy link to clipboard
Copied
Add this as the custom validation script:
if (this.getField("InflowCFM").valueAsString == "0") event.value = "";
Copy link to clipboard
Copied
Perfect, try67. I appreciate that.
Also, Thank you to the others helping me come to the conclusion.