Copy link to clipboard
Copied
I have a declared date field in an Acrobat form that I want populated as a default with the current date (though it should also be editable). I put Date() in the Calculate field on the form but that doesn't work. Any ideas?
Copy link to clipboard
Copied
Do you want this set when the PDF is opened, in all cases? Or is there a situation where is should not change?
Remove the calculation script.
Here is some code that will set the field to the current date when it is opened, but only if the field is blank.
Place this code in a document script and change the field name to your date field, and change the formatting to the date format you want.
var fld = this.getField("MyDate");
if(fld.value = "")
fld.value = util.printd("dd-mm-yy",new Date());
Copy link to clipboard
Copied
Thanks. I put this script in the Custom calculation script of my date
field, but it didn't work. Now what?
Peter Redwood
On Tue, Dec 5, 2017 at 5:39 PM, Thom Parker <forums_noreply@adobe.com>
Copy link to clipboard
Copied
Don't use a calculation script. The code was for a document script.
Here is an old article on entering document scripts, There have been some changes in the Acrobat UI, but most of the article is still acurate
https://acrobatusers.com/tutorials/js_document_scripts
Look up "Document JavaScripts" in the tool search
Copy link to clipboard
Copied
Looks tricky, but I'll give it a try. Thanks.
On Tue, Dec 5, 2017 at 10:01 PM Thom Parker <forums_noreply@adobe.com>