3 Replies Latest reply on May 18, 2015 3:19 AM by try67

    autofill date fields with today's date - Acrobat DC ?

    Mark Krisburg

      I had auto fill a form field with today's date working well in Acrobat 10, but having trouble getting it working in Acrobat DC.

       

      I have a form with 3 date fields named Date_1, Date_2, and Date_3.  I would like to set all 3 to Todays Date if the form is opened and these fields are empty.

       

      Here is the code I created:

       

      //-------------------------------------------------------------
      //-----------------Do not edit the XML tags--------------------
      //-------------------------------------------------------------

      //<Document-Level>
      //<ACRO_source>Enter Todays Date If Blank</ACRO_source>
      //<ACRO_script>
      /*********** belongs to: Document-Level:Enter Todays Date If Blank ***********/
      function EnterTodaysDateIfBlank()
      {
      var f = this.getField("DATE_1");
      if (!f.value) f.value = util.printd ("m/d/yyyy", new Date());
      var f = this.getField("DATE_2");
      if (!f.value) f.value = util.printd ("m/d/yyyy", new Date());
      var f = this.getField("DATE_3");
      if (!f.value) f.value = util.printd ("m/d/yyyy", new Date());
      }

      //</ACRO_script>
      //</Document-Level>

      _________________________________________________________________________

       

      I see no JavaScript error message for the above.  I am not sure how to "trigger" execution of this function upon form opening.

       

      There is ample documentation for this on earlier versions of Acrobat on the web, but very little posted on Acrobat DC.

        • 1. Re: autofill date fields with today's date - Acrobat DC ?
          try67 MVP & Adobe Community Professional

          Script support in Acrobat DC is identical to that of XI.

          The script you have should work if you place it as a doc-level script, WITHOUT all of the XML tags.

          • 2. Re: autofill date fields with today's date - Acrobat DC ?
            Mark Krisburg Level 1

            Script.png

            The only script that I added was the above, using the Acrobat DC tool "JavaScript", and selecting the tab "Document Javascripts".

             

            The XML tags were all added by the Acrobat DC program itself, and are what is displayed when I select the "All Javascripts" tab of the JavaScript tool,

             

            I am finding that this code does not appear to "run" when the document is opened.  Perhaps there is one other step I need to make to "trigger" it to run upon document opening.

             

            The user interface with DC is a bit different than Acrobat X Pro, and therefore I was looking for help to determine if there is an additional "step" that I overlooked to get it to trigger on document opening.

            • 3. Re: autofill date fields with today's date - Acrobat DC ?
              try67 MVP & Adobe Community Professional

              Using Acrobat XI when I click on Document JavaScripts it's empty. I don't

              know if DC does things in a drastically different way, but I doubt it. I

              suspect that somehow the code in your file got corrupt. If you can I would

              suggest to go back to a version before any of the code was added and

              starting over from there.

               

              Even if the code is correct, though, it doesn't seem like you're calling

              the function anywhere in it.

              There should be a call that looks something like this, before or after the

              function definition:

              EnterTodaysDateIfBlank();

               

              On Mon, May 18, 2015 at 12:15 PM, Mark Krisburg <forums_noreply@adobe.com>