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

Auto Fill a Date Text Field... but only once.

Community Beginner ,
Dec 07, 2017 Dec 07, 2017

Copy link to clipboard

Copied

Under Page Properties, I am using a script for an action upon opening the document in order to automatically populate the current date.

Generally, once a user completes the form for the day, they will Save As that date. December 7, 2017 is usually saved as 120717.

The script works as it should. The problem is when you open the saved form to revew it, the date changes to the day you're opening.

How can I modify the following script or action to only populate the date once and never allow it to change?

Under page properties, action tab, I selected page open as the trigger for the following script...

var f = this.getField("Date");

f.value = util.printd("mmm/d/yyyy", new Date());

Views

432

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 ,
Dec 07, 2017 Dec 07, 2017

Copy link to clipboard

Copied

LATEST

Change the second line of your code to:

if (f.valueAsString=="") f.value = util.printd("mmm/d/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