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

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

New Here ,
Mar 01, 2018 Mar 01, 2018

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

Use this code:

if (this.getField("Date").valueAsString=="") this.getField("Date").value = util.printd("dd-mmm-yyyy", new Date());

Translate
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

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.

Translate
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

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

Translate
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

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.

Translate
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
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();

Translate
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

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.

Translate
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

On what kind of devices will this form be downloaded?

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

Translate
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

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

Translate
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