6 Replies Latest reply on Jan 11, 2012 5:05 AM by enrico68

    Fields visibility driven by a calculated field

    enrico68 Level 1

      I'm developing a form for electronic signature and I want to drive the process showing the signature fields at specific events. In detail I want that signature fields appears when a calculated field (TOTCHK) has a specific value. This Check is performed when a first digital signature field is signed ( tab Digital Signature Properties>Signed>"This script executes when field is signed")

       

      // Verify Check
      var aTOTCHK = this.getField("TOTCHK").value;

      if(aTOTCHK > '999')
      {this.getField("SignatureCheckedBy1").display = display.visible;
      this.getField("SignatureCheckedBy2").display = display.visible;
      this.getField("SignatureCheckedBy3").display = display.visible;
      this.getField("SignatureCheckedBy4").display = display.visible;
      this.getField("SignatureCheckedBy5").display = display.visible;
      this.getField("SignatureCheckedBy6").display = display.visible;
      this.getField("SignatureCheckedBy7").display = display.visible;}
      else if(aTOTCHK > '99')
      {this.getField("SignatureApprovedBy").display = display.visible;}
      else if(aTOTCHK > '9')
      {this.getField("SignatureAgreedBy1").display = display.visible;
      this.getField("SignatureAgreedBy2").display = display.visible;
      this.getField("SignatureAgreedBy3").display = display.visible;
      this.getField("SignatureAgreedBy4").display = display.visible;
      this.getField("SignatureAgreedBy5").display = display.visible;
      this.getField("SignatureAgreedBy6").display = display.visible;
      this.getField("SignatureAgreedBy7").display = display.visible;}
      else if(aTOTCHK > '0')
      {this.getField("SignatureAuthorizedBy").display = display.visible;}
      else{this.getField("SignatureArchivedBy").display = display.visible;}

       

      The check fails and the condition is the first OR the "else". The "else if" conditions are not taken in account. Is there any error in the JS code? The format of TOTCHK is number

      Thank You in advance ..

        • 1. Re: Fields visibility driven by a calculated field
          try67 MVP & Adobe Community Professional

          You need to drop the quotes around the numbers. These are actual numbers,

          not strings.

          Also, you might want to explicitly convert the value of the field you're

          checking into a number, like so (notice the plus sign):

           

          var aTOTCHK = +this.getField("TOTCHK").value;

          • 2. Re: Fields visibility driven by a calculated field
            enrico68 Level 1

            Hi try67,

            I tried but it's still not working. And I have to modify the previous posting: anytime is NOT working (always the "else" condition is taken). Any other idea?

             

            // Verify Check
            var aTOTCHK = +this.getField("TOTCHK").value;

            if(aTOTCHK > 999)
            {this.getField("SignatureCheckedBy1").display = display.visible;
            this.getField("SignatureCheckedBy2").display = display.visible;
            this.getField("SignatureCheckedBy3").display = display.visible;
            this.getField("SignatureCheckedBy4").display = display.visible;
            this.getField("SignatureCheckedBy5").display = display.visible;
            this.getField("SignatureCheckedBy6").display = display.visible;
            this.getField("SignatureCheckedBy7").display = display.visible;}
            else if(aTOTCHK > 99)
            {this.getField("SignatureApprovedBy").display = display.visible;}
            else if(aTOTCHK > 9)
            {this.getField("SignatureAgreedBy1").display = display.visible;
            this.getField("SignatureAgreedBy2").display = display.visible;
            this.getField("SignatureAgreedBy3").display = display.visible;
            this.getField("SignatureAgreedBy4").display = display.visible;
            this.getField("SignatureAgreedBy5").display = display.visible;
            this.getField("SignatureAgreedBy6").display = display.visible;
            this.getField("SignatureAgreedBy7").display = display.visible;}
            else if(aTOTCHK > 0)
            {this.getField("SignatureAuthorizedBy").display = display.visible;}
            else{this.getField("SignatureArchivedBy").display = display.visible;}

            • 3. Re: Fields visibility driven by a calculated field
              try67 MVP & Adobe Community Professional

              First of all, you need to hide the fields. I suggest you first hide them all, and then run this code. Otherwise once a field has been set to visible, it will remain so.

              Also, do you have any error messages in the console?

              • 4. Re: Fields visibility driven by a calculated field
                enrico68 Level 1

                The signature fields are all hidden and the script should make visible the correct ones depending on the value. No indications are in the JS debugger consolle while filling the form. This is the only message

                 

                Acrobat EScript Built-in Functions Version 10.0

                Acrobat SOAP 10.0

                 

                I don't know if it's important: I'm using AcrobatX Pro

                • 5. Re: Fields visibility driven by a calculated field
                  try67 MVP & Adobe Community Professional

                  From which event are you launching this code?

                  • 6. Re: Fields visibility driven by a calculated field
                    enrico68 Level 1

                    Sorry try67, I made a beginner error ..... The name of the field was mistyped (due to the initial creation of "multiple fields"). ("TOTCHK" was typed as "TOTCHK.0") :-(

                    With Your suggestion about the format now is all working

                    Thank You for the support