5 Replies Latest reply on Oct 25, 2017 2:30 PM by try67

    Date field populates with today's date when Signature signed via sigpad

    buddycafe

      Hello,

       

      I'm able to populate today's date to a single field by inserting this script to the Signature field.

       

      this.getField("Datefield1").value = util.printd ("m/d/yyyy", new Date());

       

      How can I do an "OR" to the above script so I can insert 5 fields? Reason being is the naming convention of the date field can be five different names.

      Datefiled1

      Datefiled2

      Datefiled3

      Datefiled4

      Datefiled5

       

      Instead of going into the script and edit the Datefield, I just want the script to work for any of the five.

      I tired this but no luck....

      this.getField(("Datefield1")||("Datefield2")).value = util.printd ("m/d/yyyy", new Date());

       

      Thank you

      Ed

        • 1. Re: Date field populates with today's date when Signature signed via sigpad
          gkaiseril MVP & Adobe Community Professional

          The "||" is the logical OR operator and is used in logical expressions. You can not use it for a field name in the getField method. Logical expressions are statements the evaluate to either a logical value of true or false.  The logical OR statement is used to evaluate the result of two logical statements to one logical value. Following is the truth table for the logical OR.

           

          OR    |  true  |  false |

          -------+--------+--------+

          true   |  true  }  true   |

          -------+--------+--------+

          false |  true  }  false  |

          -------+--------+--------+

           

          If either statement or both statements are true the result is true. The false value is only possible if both statements are false.

           

          I would create a variable with the current date and then assign that variable's value to each date field.

          • 2. Re: Date field populates with today's date when Signature signed via sigpad
            buddycafe Level 1

            Thanks for the reply gkaiseril

             

            The problem I have with setting a variable with a current date is because the variable must be unique (up to five) depending on the content of the form. To clarify 'unique', these variables are going to be captured by vendor when the form is submitted via API interface. The vendor identifies if it's either Field1, Field2, Field3, etc and processes this form on their end.

             

            Rather than constantly editing the script in the signature field, I'm hoping a script can be written in such a way that it responds on the condition that the date field are any of the five variables noted above. Hope this makes sense.

            • 3. Re: Date field populates with today's date when Signature signed via sigpad
              try67 MVP & Adobe Community Professional

              Your condition is not very clear... Based on what do you want to decide which field to populate, exactly?

              • 4. Re: Date field populates with today's date when Signature signed via sigpad
                buddycafe Level 1

                I inserted the script noted above to a signature field.

                 

                this.getField("Datefield1").value = util.printd ("m/d/yyyy", new Date());

                 

                When signing, today's date populates on the neghboring non-sig field called Datefield1. The issue im running into is that the variable name of the date field is not always Datefield1. It can also be Datefield2, Datefield3, Datefield4,Datefield5. Depending on the content of the form. Instead of repeatedly going into the signature field and edit the script, I was wondering if a script can be written that says, When the sig field is signed, populate today's date on the date field where the date field can be any of the five variables.

                Sorry, I hope this is a bit more clear.

                • 5. Re: Date field populates with today's date when Signature signed via sigpad
                  try67 MVP & Adobe Community Professional

                  A weird set-up, but I understand what you mean now. You can use this code:

                   

                  for (var i=1; i<=5; i++) {
                      var f = this.getField("Datefield"+i);
                      if (f!=null) f.value = util.printd ("m/d/yyyy", new Date());   
                  }