Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Create timestamp when form is completed/saved

New Here ,
Aug 29, 2016 Aug 29, 2016

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!

TOPICS
Acrobat SDK and JavaScript , Windows
799
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 29, 2016 Aug 29, 2016

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 29, 2016 Aug 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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 29, 2016 Aug 29, 2016
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines