Copy link to clipboard
Copied
var J = Number(this.getField("V10").valueAsString);
var K = eval(this.getField("F10").valueAsString);
var d = Number(this.getField("H1").valueAsString);
var e = this.getField("D10").valueAsString;
var f = Number(this.getField("I1").valueAsString);
event.value = "";
if (e !== "") {
e = Number(e);
if (e === 0) {
event.value = "<LOD";
} else {
var total;
if (J !== 0 && f !== 0) {
total = (K * d) / (J * f);
event.value = total.toFixed(3);
}
}
}
Hi,
in above script when I write 0/100 in K, the value appearing correct in E. But when I write 1/100 is F. Attached pdf link for file.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
J7 is zero so the result of this formula is invalid (since division by zero is not allowed):
total = (K * d) / (J * f);
Copy link to clipboard
Copied
can you tell me correct script to get the result.
Copy link to clipboard
Copied
What is the desired result in case J or F are zero?
Copy link to clipboard
Copied
I require the calculation to produce a valid result even if the values of J and f are 0. The calculation should utilize the available fields to generate a meaningful outcome, rather than yielding an invalid result. Considering them as 1 might suffice, but I'm uncertain. I'm open to any solution that ensures the calculation behaves appropriately.
Copy link to clipboard
Copied
There is no valid result in this scenario. The field should remain empty, in my opinion.
Copy link to clipboard
Copied
I need the cell shows value. Is there any option we can achieve that?
Copy link to clipboard
Copied
Use another condition:
if (J == 0 && f == 0) {
total = (K * d); ?
Copy link to clipboard
Copied
Thanks it worked when I add this condition too with considering blank value as 1
Copy link to clipboard
Copied
I used this
var J = Number(this.getField("V1").valueAsString);
var K = eval(this.getField("F1").valueAsString);
var d = Number(this.getField("H1").valueAsString);
var e = this.getField("D1").valueAsString;
var f = Number(this.getField("I1").valueAsString);
event.value = "";
if (e !== "") {
e = Number(e);
var total;
if (J !== 0 && f !== 0) {
total = (K * d) / (J * f);
} else if (J === 0 && f === 0) {
total = K * d;
} else if (J === 0) {
total = (K * d) / f;
} else {
total = (K * d) / J; // If f is 0,
}
event.value = total.toFixed(3);
}
Copy link to clipboard
Copied
What value, exactly?