Skip to main content
Participant
May 27, 2020
Question

After Submit - Do Not Update Date & Time, Do Not Ask to Save

  • May 27, 2020
  • 1 reply
  • 1352 views

I have a form that will have the date (and time) automatically populated when the user completes the form.  I have the JavaScript to auto populate the date and time when the form is opened.  The issue I have is that after the form is submitted using a submit button (currently the completed form is sent via email, but will eventually be through a URL), and the completed document is opened by the recipient, the date and time updates again.  How can I disable the auto population of the date and time after the document has been submitted so that it retains the original date and time of the submission?  Note, the completed document is not going to be saved or printed until after the recipient receives and reviews it.  After the form is submitted it also resets the form, except for the date and time.  I also want the form to automatically close, not ask the user to save and Adobe to close.  I added the File, Close feature to the button, but it asks the user if they would like to save.  I am using Adobe Acrobat Pro 2017.

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
May 28, 2020

- Add a (hidden) check-box to the file and change your doc-level script to only update the date/time field if it is unchecked.

Then add a command to the Submit button to check it before submitting.

 

- You can close the file without saving it using this JavaScript code:

this.closeDoc(true);

I would advice against doing that, though. You could seriously annoy your users by closing the file with the data they filled in without giving them a chance to save it first... And you can't close the application entirely.

MHLLPAuthor
Participant
May 28, 2020

Thank you try67.  I am running into an issue after adding the "if" statement to the doc-level script.  The error message appears after the script is saved and closed - Invalid date/time for the Today field.  It then gives the format of m/d/yyyy h:MM tt.  The Today field does exist and is a text box with a format of m/d/yyyy h:MM tt.  I am assuming my script is written incorrectly.  Any assistance would be much appreicaited!  

 

Below I have included the current code, the original code and a screensshot of the error message.

 

if (event.value=="")
{this.getField("Check").value="Off"}
else
{this.getField("Today").value=" mm/dd/yyyy h:MM tt", new Date()};

 

My original code that generated the date/time is 

if (this.getField("Today"))

{this.getField("Today").value=util.printd("mm/dd/yyyy h:MM tt", new Date())}

 

 

try67
Community Expert
Community Expert
May 28, 2020

Use this:

 

if (this.getField("Today").valueAsString=="")

{this.getField("Today").value=util.printd("mm/dd/yyyy h:MM tt", new Date())}