10 Replies Latest reply on Jun 14, 2016 10:42 AM by willkirt

    Date autofill with signature

    willkirt

      I created a form with adobe that requires digital signatures from at least 3 people. Everything is fine until my auto fill script dates the signature. For some reason all the signatures will be dated to match the most recent signature. Here is my script:

       

      Signature field 1:

      var a = this.getField("PROVIDER SIGNATURE").value;

      if( a > "0") {event.value = util.printd("yyyymmdd", new Date())} else {event.value = ""}

       

      Signature field 2:

      var b = this.getField("FLIGHT SURGEON SIGNATURE").value;

      if( b > "0") {event.value = util.printd("yyyymmdd", new Date())} else {event.value = null}

       

      Signature field 3:

      var c = this.getField("MEMBER SIGNATURE").value;

      if( c > "0") {event.value = util.printd("yyyymmdd", new Date())} else {event.value = null}

       

      Signature field 4:

      var d = this.getField("COMMANDER SIGNATURE").value;

      if( d > "0") {event.value = util.printd("yyyymmdd", new Date())} else {event.value = null}

       

      At least three of the four field have to be signed but if the Provider and the Soldier sign on 20160305 and the Commander signs three days later, it changes the dates for the Provider and Soldiers signatures to the same date as the Commander.

        • 1. Re: Date autofill with signature
          try67 MVP & Adobe Community Professional

          When comparing numbers do not put double-quotes around them. It converts them to strings and the mathematical operators will not work (correctly) on them.

          • 2. Re: Date autofill with signature
            willkirt Level 1

            If I remove to quotation marks from the "0" it no longer dates the field. The real issue I am having though, because for the most part it works, is that when the form gets sent to the Commander for signature, all the signature date fields that have been signed get redated to match when he signed. I thought that giving each signature block its own variable would fix this because each event would be tied to that event. What appears to be happening, as far as I can tell. the event will happen for any variable that is greater then 0. so any block that is signed will be redated with each new signature. Could I separate the events like event1.value, event2.value, or is there another way?

            • 3. Re: Date autofill with signature
              try67 MVP & Adobe Community Professional

              I don't quite understand what you're trying to do, to be honest... When you

              sign a digital signature field it will automatically contain the time it

              was signed. There's no need to use any script for that.

              • 4. Re: Date autofill with signature
                willkirt Level 1

                I understand that but it tiny and difficult for some to see. To make it easier for some of our older staff and the like they want it in its own block so it can be readily identified.

                • 5. Re: Date autofill with signature
                  try67 MVP & Adobe Community Professional

                  OK... Where are you placing this code, though?

                  Also, why are you using "null" in some lines and an empty string in others?

                  • 6. Re: Date autofill with signature
                    willkirt Level 1

                    Because i don't know much about Java. I created this by looking up code and piecing things together. It has been a lot of trial and error and I have finally hit a point I can't get passed because I just don't understand enough of the code to know where the issue actually lies.

                     

                    The script is placed in the custom calculation box in the properties of the date field.

                    • 7. Re: Date autofill with signature
                      try67 MVP & Adobe Community Professional

                      OK, I see. I would use a different approach. You see, the calculation script executes each time the value of any field is changed, so you keep updating the values, even when you don't want them to change. Instead, I would use the Signed event of the signature fields themselves to update the text fields. The script there would be pretty simple. Something like:

                       

                      this.getField("SignatureDate").value = util.printd("yyyymmdd", new Date());

                      1 person found this helpful
                      • 8. Re: Date autofill with signature
                        willkirt Level 1

                        Can I do this and still have the signature lock fields? That was why I put it in the date field and not the signature. Once the Provider signs it I need certain fields to become read only so that when it goes to the next person in line for signature they can't manipulate and change what the Doctor said.

                        • 9. Re: Date autofill with signature
                          try67 MVP & Adobe Community Professional

                          Yes, you can still do it by using a script that sets those fields as

                          read-only, like so:

                          this.getField("FieldName").readonly = true;

                          1 person found this helpful
                          • 10. Re: Date autofill with signature
                            willkirt Level 1

                            That seems to have done the trick. Thank you.