Copy link to clipboard
Copied
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!
Copy link to clipboard
Copied
You can use the document's Will Save event to do that. You'll find it under Tools - JavaScript - Set Document Actions.
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now