Skip to main content
Participant
August 29, 2016
Question

Create timestamp when form is completed/saved

  • August 29, 2016
  • 1 reply
  • 859 views

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!

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
August 29, 2016

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

Participant
August 29, 2016

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?

Inspiring
August 29, 2016

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.