Keep today's date

New Here ,
Feb 17, 2021 Feb 17, 2021

Copy link to clipboard

Copied

Hi

 

I used this script to insert today's date. 

this.getField("Today").value = util.printd("mm/dd/yyyy", new Date());

Will this keep a static date if the saved form is opened later? 

If not, is there a scrip to use so it doesn't change later.

 

thanks

Leah

TOPICS
PDF forms

Views

177

Likes

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

correct answers 1 Correct Answer

Adobe Community Professional , Feb 18, 2021 Feb 18, 2021
This script will only fill the "Today" field if it is empty, otherwise nothing will happen: var oField = this.getField("Today"); if (oField != null && oField.value.length == 0) {oField.value = util.printd("mm/dd/yyyy", new Date());}

Likes

Translate

Translate
Adobe Community Professional ,
Feb 17, 2021 Feb 17, 2021

Copy link to clipboard

Copied

Where does you use the script?

Likes

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
New Here ,
Feb 18, 2021 Feb 18, 2021

Copy link to clipboard

Copied

Hi Betreff

thanks for replying

It's in a document Java Script

Likes

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
Adobe Community Professional ,
Feb 18, 2021 Feb 18, 2021

Copy link to clipboard

Copied

Fill the field only when it is empty,

Likes

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
Adobe Community Professional ,
Feb 18, 2021 Feb 18, 2021

Copy link to clipboard

Copied

This script will only fill the "Today" field if it is empty, otherwise nothing will happen:

 

var oField = this.getField("Today");
if (oField != null && oField.value.length == 0) {oField.value = util.printd("mm/dd/yyyy", new Date());}

Likes

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
New Here ,
Feb 18, 2021 Feb 18, 2021

Copy link to clipboard

Copied

thank you so much JR

My other script was a Java Script. I've put your code in as a Java Script and it's not working.

Is this the right spot for your script or should it go somewhere else?


thanks
Leah

Likes

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
New Here ,
Feb 18, 2021 Feb 18, 2021

Copy link to clipboard

Copied

To clarify, my other code was in a Document Java Script

Likes

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
Adobe Community Professional ,
Feb 20, 2021 Feb 20, 2021

Copy link to clipboard

Copied

LATEST

It should works fine as a Document JavaScript

Likes

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
Most Valuable Participant ,
Feb 18, 2021 Feb 18, 2021

Copy link to clipboard

Copied

If the code is run it will update the field. It is up to you to make sure you only run it once, or modify it so it does nothing if the field is not blank.

Likes

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