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

Auto Updating Date field script - Needs to udate date first time opened not each time

New Here ,
Mar 01, 2018 Mar 01, 2018

Copy link to clipboard

Copied

I have a for that has an auto updating date field using the following script: getField("Date").value = util.printd("dd-mmm-yyyy", new Date()); The problem is once the form is completed and saved under a different name it continues to update the date field every time it is opened. I need this form to udate the date only the first time it is opened any subsequent time the form is opened I need it to retain the original date from when the form was completed and saved.

Would anyone be able to provide some guidance as to how to alter this field or create a new field that will only set the date once.

I am using Adobe Acrobe Pro 2017 release date and the form needs to support digital signature

Any help would be greatly appreciated.

TOPICS
Acrobat SDK and JavaScript , Windows

Views

364

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 ,
Mar 01, 2018 Mar 01, 2018

Copy link to clipboard

Copied

Use this code:

if (this.getField("Date").valueAsString=="") this.getField("Date").value = util.printd("dd-mmm-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 ,
Mar 01, 2018 Mar 01, 2018

Copy link to clipboard

Copied

Thanks for your response and it seem to work with regards to not altering the date but it seems to be picking up the current date now and storing that in the document. I need to save the document is such a manner so that when someone downloads it and then opens the pdf, it fills in the current date for the user at that time.

I know very little about this so I may be doing something wrong.

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 ,
Mar 01, 2018 Mar 01, 2018

Copy link to clipboard

Copied

Just reset the form and then save it before uploading it to the server.

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 ,
Mar 02, 2018 Mar 02, 2018

Copy link to clipboard

Copied

Sorry to ask probably a stupid question but how would one reset the form before submitting uploading it to the server that it will be housed on.

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 ,
Mar 02, 2018 Mar 02, 2018

Copy link to clipboard

Copied

LATEST

Not submitting it, uploading it to the server... It's not the same.

You would do it by opening it in Acrobat, then going to Tools - Forms - More Form Options - Clear Form.

You can also do it by running this code from the JS Console:

this.resetForm();

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 ,
Mar 01, 2018 Mar 01, 2018

Copy link to clipboard

Copied

Thanks for your response and it seem to work with regards to not altering the date but it seems to be picking up the current date now and storing that in the document. I need to save the document is such a manner so that when someone downloads it and opens it fills in the current date for the user at that time.

I know very little about this so I man be doing something wrong.

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 ,
Mar 01, 2018 Mar 01, 2018

Copy link to clipboard

Copied

On what kind of devices will this form be downloaded?

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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 ,
Mar 01, 2018 Mar 01, 2018

Copy link to clipboard

Copied

It will be used on a PC or Laptop. Could be running Windows or MAC OS. most likely Windows

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