Skip to main content
htlfmanning
Participant
April 12, 2017
Answered

How would you set up a variable date field that shows the current date, but then locks upon saving the form?

  • April 12, 2017
  • 1 reply
  • 4429 views

I am trying to set up a disclosure statement that displays the current date when it first displays within an app. Once a customer were to save the form, I need that date to lock to that particular date and no longer update. 

This topic has been closed for replies.
Correct answer Joel Geraci

But they only want it to update once, not each time...


Right... you'd add a document level script that runs each time the file is opened but a conditional statement first checks if the date field has a value set the date only when that's not the case. The field would already be readonly. Something like...

var dateField = this.getField("date");

if (dateField.value == "") {

    dateField.value = util.printd("mmmm dd, yyyy", new Date());

}

If you reset the form before distribution, the date field is blank. It gets filled when the file is opened and assuming they aren't filling it while flying over the international date line, the date that they open the form will be the same date that they save it. The field value gets saved when the file is saved. Not saving the form leaves the value as empty even though a value is visible before you close the file without saving.

1 reply

Legend
April 12, 2017

There's a conceptual problem...won't it lock when YOU save it?

try67
Community Expert
Community Expert
April 12, 2017

You can get around that by disabling JS before saving the file on your end...

try67
Community Expert
Community Expert
April 12, 2017

Another problem is that you can't force someone to save the file they opened, so the date will not become a part of it until they do.

They can just download the file, open it, and then close it without saving over and over.