Copy link to clipboard
Copied
I am trying to get the PASS/FAIL field to say Pass if the % Comp is over 95% and Fail if is it less than 95%. Unfortunately, I'm not finding the right combination to get it to work when I change the value. The % Comp is a value that is calculated from other cells as well, I'm not sure if that is the problem or now.
Copy link to clipboard
Copied
OK, and I'm assuming the value of "Required" is the threshold, not a fixed value. In that case, use this code as the custom calculation script of "Field 1":
var v1 = Number(this.getField("Comp").valueAsString);
var v2 = Number(this.getField("Required").valueAsString);
event.value = (v1>v2) ? "PASS" : "FAIL";
Copy link to clipboard
Copied
Is the other field defined as a Percentage field (under Format)? What is the name of this field?
Should the threshold value be hard-coded as 95%, or is is the value of the "REQUIRED" field? If the latter, what is the name of that field, as well?
Copy link to clipboard
Copied
Yes they are both formated at percentage.
Right now % Comp is labeled at "Comp", Required = "Required", and Pass/Fail = "Field 1"
Copy link to clipboard
Copied
OK, and I'm assuming the value of "Required" is the threshold, not a fixed value. In that case, use this code as the custom calculation script of "Field 1":
var v1 = Number(this.getField("Comp").valueAsString);
var v2 = Number(this.getField("Required").valueAsString);
event.value = (v1>v2) ? "PASS" : "FAIL";
Copy link to clipboard
Copied
Thank you so much, that worked!!!!!!
Copy link to clipboard
Copied
Thanks for this. I'm performing a very similar calculation. The above script produces a "Pass" result when the calculated fields are blank. How can that be changed to remain blank or display "--" until data is input into the calcuated fields?
Copy link to clipboard
Copied
Replace "FAIL" with "" or "--"
Copy link to clipboard
Copied
Thanks. So to clarify, there are three conditions here that I'd like the pass/fail field to display
1.) "--" when the %Comp field is blank,
2.) "Fail" when the %Comp field is less than the Req'd field, and
3.) "Pass" when the %Comp field is greater than or equal to the Req'd field.
how do i modify the script to achieve this?
Thanks so much for the help!
Copy link to clipboard
Copied
var cV1 = this.getField("Comp").valueAsString;
if((cV1 = "") || isNaN(cV1))
event.value = "--";
else
{
var v1 = Number(cV1);
var v2 = Number(this.getField("Required").valueAsString);
event.value = (v1>v2) ? "PASS" : "FAIL";
}
Find more inspiration, events, and resources on the new Adobe Community
Explore Now