Copy link to clipboard
Copied
Hi. I have created a form where the "form date" auto-populates to the day it was opened (using this Javascript: this.getField("WED").value = new Date;). We would like that date to remain constant throughout the multiple openings and editings, but it seems to give the current date whenever opened. Is this possible?
Thanks
Copy link to clipboard
Copied
Update to the debacle:
In Acrobat Standard 2020, you must:
click Page Thumbnails
r click Page Properties
enter script on Actions tab
That made it work...only then did we realize that the date would be stuck on the date of the fix lolololol. Thanks for everyone's help through this.
Copy link to clipboard
Copied
Add date only if field is empty.
if(this.getField("WED").valueAsString == "")
this.getField("WED").value = new Date;
Copy link to clipboard
Copied
Thanks Nesa! I will plug this in and let you know tomorrow.
Copy link to clipboard
Copied
Hi Nesa, that is not working. When opening the document, you can see the prior date for a split second before it changes to the current date. Maybe I did not enter the calculation script correctley?
Copy link to clipboard
Copied
You should add script at document level.
Select 'Prepare form' tool, then click on 'More' then select 'Document Javascript', now give it a name and click 'add' then delete anything that is in editor that appears and paste script inside.
Copy link to clipboard
Copied
I do not see that under More
Copy link to clipboard
Copied
What software version do you use?
You can also open document JavaScript by selecting 'Prepare form' tool and press SHIFT+D on windows.
Copy link to clipboard
Copied
I am using Acrobat Standard 2020. This tab is the only one remotely close to what you are describing
Copy link to clipboard
Copied
Sorry, I was on vacation. The issue still exists, and I am lost regarding your last post
Copy link to clipboard
Copied
Select 'Prepare form' tool and press SHIFT+D to open document javascript.
Copy link to clipboard
Copied
Nesa, SHIFT + D does not open anything, but CNTRL + D opens my Document Properties, and I entered in the script as seen in my last upload prior to todays post. Thank you for helping with this
Copy link to clipboard
Copied
CTRL+D opens document properties, JavaScript should not go there.
I don't use acrobat standard 2020, so I can't be sure, but when selected 'Prepare form' tool and click on 'More' there should be an option for 'Document JavaScript'.
There is also tool 'Document Javascripts':
You can also select 'Prepare form' tool and then press Shift+D it should open 'Document JavaScript'.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
'Document JavaScript' is not available in the Standard edition.
Copy link to clipboard
Copied
But you can still apply doc-level scripts, using this command (from the JS Console):
this.addScript("load", "if(this.getField(\"WED\").valueAsString == \"\") this.getField(\"WED\").value = new Date;");
Copy link to clipboard
Copied
I found a coworker who has an Adobe subscription with all of the bells and whistles, and we were able to add the java script in using her laptop. I'll let you know how it went tomorrow. Thanks!
Copy link to clipboard
Copied
The change that we made did not work. Here is a screenshot of what was entered.
Copy link to clipboard
Copied
What exactly don't work?
The script you added will populate "WED" field with current date, only if "WED" field is empty.
Copy link to clipboard
Copied
We have an issue with HR not notifying us in a timely manner when employees quit or are fired...leaving a gaping hole in our network security until we make our changes. This form will be initiated by HR, then sent to us. My boss wants this form to populate the current date when HR starts the form, and for that date to remain throughout all edits and saves down the road. (So when Joe gets fired on Monday the 1st, but HR does not notify us until the 17th, the form date cannot be back dated to cover their tracks).
We made the above changes last week, then edited and saved it, so the form date should maintain at June 2nd, but opening it again this morning it reads June 5th. I hope that I explained that properly.
Copy link to clipboard
Copied
I just tested this with both Acrobat and Reader by populating the date, saving and then setting my system date to a later date and opening the file it retains the populated date.
Are you using some other software to open the file?
Copy link to clipboard
Copied
I am only using Acrobat Standard 2020. We do have many different versions being used throughout our company though. This should not be a version specific issue once the javascript is inserted.
Copy link to clipboard
Copied
You can also replace that script with non-working script when "WED" field populates, so it shouldn't populate anymore. Try using this as 'Validate' script of "WED" field:
if(event.value !== "")
this.addScript("load", "function(){ /* Empty script */ }");
Copy link to clipboard
Copied
This won't work in Reader. The original code you posted should work fine.
Copy link to clipboard
Copied
Update to the debacle:
In Acrobat Standard 2020, you must:
click Page Thumbnails
r click Page Properties
enter script on Actions tab
That made it work...only then did we realize that the date would be stuck on the date of the fix lolololol. Thanks for everyone's help through this.
![](/skins/images/D3C41BFA2DFE1D715C1CD7198102A9D8/responsive_peak/images/icon_anonymous_message.png)
![](/skins/images/D3C41BFA2DFE1D715C1CD7198102A9D8/responsive_peak/images/icon_anonymous_message.png)