Skip to main content
Participant
March 1, 2018
Question

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

  • March 1, 2018
  • 2 replies
  • 686 views

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.

This topic has been closed for replies.

2 replies

kfs1Author
Participant
March 1, 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.

Thom Parker
Community Expert
Community Expert
March 1, 2018

On what kind of devices will this form be downloaded?

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
kfs1Author
Participant
March 1, 2018

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

try67
Community Expert
Community Expert
March 1, 2018

Use this code:

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

kfs1Author
Participant
March 1, 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.

try67
Community Expert
Community Expert
March 1, 2018

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