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

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

583

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

Community Expert , 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());}

Votes

Translate

Translate
Community Expert ,
Feb 17, 2021 Feb 17, 2021

Copy link to clipboard

Copied

Where does you use the 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
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

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

Copy link to clipboard

Copied

Fill the field only when it 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
Community Expert ,
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());}

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

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

Copy link to clipboard

Copied

To clarify, my other code was in a Document Java 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 ,
Feb 20, 2021 Feb 20, 2021

Copy link to clipboard

Copied

LATEST

It should works fine as a 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
LEGEND ,
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.

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