3 Replies Latest reply on Aug 30, 2016 2:05 PM by gkaiseril

    Create timestamp when form is completed/saved

    michellearc

      I have a form that has javascript to display today's date when the form is open.  How can I create additional javascript that will add the time the form was completed/saved?  I'm using Adobe Acrobat Pro DC. Thanks!

        • 1. Re: Create timestamp when form is completed/saved
          try67 MVP & Adobe Community Professional

          You can use the document's Will Save event to do that. You'll find it under Tools - JavaScript - Set Document Actions.

          • 2. Re: Create timestamp when form is completed/saved
            michellearc Level 1

            Thanks!  I'm not sure if I set up the javascript correctly - it's not working.  I created a new text box for the time, but when I tested the form, the time is not showing in the saved version.  Here is the script:

            var f = this.getField("Time");

            f.value = util.printd("HH:MM");

            //</ACRO_script>

            //</Page-Actions>

             

            //</ACRO_script>

            //</Document-Level>

             

            Is that not correct?

            • 3. Re: Create timestamp when form is completed/saved
              gkaiseril MVP & Adobe Community Professional

              Your statement to insert the formatted time is missing the second parameter (the date object) .

               

              Do you get any messages when try to print the document?

               

              I get the following message:

               

              >>MissingArgError: Missing required argument.

              >>Util.printd:2:Doc undefined:Will Print

              >>===> Parameter oDate.

               

              in the JavaScript console.

               

              Open the JavaScript console, <Ctrl> + "J" keys, to see if there are any errors. I have the Preferences for Acrobat set to "Show console errors and messages".

               

              You can try this script for the "Will Save" action.

               


              var f = this.getField("Time");
              f.value = util.printd("HH:MM", (new Date()) );

               

              The "(new Date())" is the missing date object parameter.

               

              Also make sure you have spelled and capitalized the field name the same as the field.