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

Auto-populated form date

Explorer ,
May 23, 2023 May 23, 2023

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

TOPICS
PDF forms

Views

3.9K

Translate

Translate

Report

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
1 ACCEPTED SOLUTION
Explorer ,
Jun 27, 2023 Jun 27, 2023

Copy link to clipboard

Copied

LATEST

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.

View solution in original post

Votes

Translate

Translate

Report

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 ,
May 23, 2023 May 23, 2023

Copy link to clipboard

Copied

Add date only if field is empty.

if(this.getField("WED").valueAsString == "")
this.getField("WED").value = new Date;

Votes

Translate

Translate

Report

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
Explorer ,
May 24, 2023 May 24, 2023

Copy link to clipboard

Copied

Thanks Nesa! I will plug this in and let you know tomorrow.

Votes

Translate

Translate

Report

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
Explorer ,
May 25, 2023 May 25, 2023

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? 

Votes

Translate

Translate

Report

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 ,
May 25, 2023 May 25, 2023

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.

Votes

Translate

Translate

Report

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
Explorer ,
May 25, 2023 May 25, 2023

Copy link to clipboard

Copied

I do not see that under More

Votes

Translate

Translate

Report

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 ,
May 25, 2023 May 25, 2023

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.

tempsnip.pngexpand image

Votes

Translate

Translate

Report

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
Explorer ,
May 25, 2023 May 25, 2023

Copy link to clipboard

Copied

I am using Acrobat Standard 2020. This tab is the only one remotely close to what you are describing

Votes

Translate

Translate

Report

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
Explorer ,
May 31, 2023 May 31, 2023

Copy link to clipboard

Copied

Sorry, I was on vacation. The issue still exists, and I am lost regarding your last post

Votes

Translate

Translate

Report

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 ,
May 31, 2023 May 31, 2023

Copy link to clipboard

Copied

Select 'Prepare form' tool and press SHIFT+D to open document javascript.

Votes

Translate

Translate

Report

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
Explorer ,
May 31, 2023 May 31, 2023

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

Votes

Translate

Translate

Report

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 ,
May 31, 2023 May 31, 2023

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':

tempsnip.pngexpand image

You can also select 'Prepare form' tool and then press Shift+D it should open 'Document JavaScript'.

Screenshot 2023-05-31 at 16-50-21 Keyboard shortcuts.pngexpand image

 

 

 

 

Votes

Translate

Translate

Report

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
Explorer ,
May 31, 2023 May 31, 2023

Copy link to clipboard

Copied

Here are some screenshots of what I am working with. 1 is the document. 2 is the tools page. It is cut off at the bottom, but no tool like you show. 3 is in forms. 4 shows what is under "more". What version are you using that has this capability?

Votes

Translate

Translate

Report

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 ,
May 31, 2023 May 31, 2023

Copy link to clipboard

Copied

'Document JavaScript' is not available in the Standard edition.

Votes

Translate

Translate

Report

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 ,
May 31, 2023 May 31, 2023

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;");

Votes

Translate

Translate

Report

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
Explorer ,
May 31, 2023 May 31, 2023

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!

Votes

Translate

Translate

Report

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
Explorer ,
Jun 05, 2023 Jun 05, 2023

Copy link to clipboard

Copied

The change that we made did not work. Here is a screenshot of what was entered. 

Votes

Translate

Translate

Report

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 ,
Jun 05, 2023 Jun 05, 2023

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.

Votes

Translate

Translate

Report

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
Explorer ,
Jun 05, 2023 Jun 05, 2023

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.

Votes

Translate

Translate

Report

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 ,
Jun 05, 2023 Jun 05, 2023

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?

Votes

Translate

Translate

Report

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
Explorer ,
Jun 05, 2023 Jun 05, 2023

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.

Votes

Translate

Translate

Report

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 ,
Jun 05, 2023 Jun 05, 2023

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 */ }");

Votes

Translate

Translate

Report

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 ,
Jun 05, 2023 Jun 05, 2023

Copy link to clipboard

Copied

This won't work in Reader. The original code you posted should work fine.

Votes

Translate

Translate

Report

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
Explorer ,
Jun 27, 2023 Jun 27, 2023

Copy link to clipboard

Copied

LATEST

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.

Votes

Translate

Translate

Report

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