Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Pass/Fail based on value of another field

New Here ,
Apr 24, 2019 Apr 24, 2019

ADOBE.PNG

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.

TOPICS
PDF forms
1.5K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
1 ACCEPTED SOLUTION
Community Expert ,
Apr 24, 2019 Apr 24, 2019

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";

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 24, 2019 Apr 24, 2019

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 24, 2019 Apr 24, 2019

Yes they are both formated at percentage.

Right now % Comp is labeled at "Comp", Required = "Required", and Pass/Fail = "Field 1"

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 24, 2019 Apr 24, 2019

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";

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 24, 2019 Apr 24, 2019

Thank you so much, that worked!!!!!!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 28, 2020 Jan 28, 2020

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 28, 2020 Jan 28, 2020

Replace "FAIL" with "" or "--"

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 29, 2020 Jan 29, 2020

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!  

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 29, 2020 Jan 29, 2020
LATEST

 

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";

}

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines