Skip to main content
Participating Frequently
July 22, 2024
Answered

Date in a PDF Form Changing when PDF is Opened Next Day - How to Lockdown the Date Field?

  • July 22, 2024
  • 2 replies
  • 1020 views

Hi,

 

I am facing an issue with a PDF form that is used and signed by mutiple people. As per the process, once first person completes his form fields, he presses the First "Completed" button and the current date must be displayed against his name in a previously hidden field (I have programmed the button to make date field visible once button is pressed). Then the form goes to second person. When the second person completes his form fields, he presses the Second "Completed" button and the current date must be displayed against his name in a previously hidden field.

 

The problem I am facing is that I am able to get the current date, but when the PDF is opened on the next day, the date keeps changing to reflect new date. I don't want this and need to lock the date field once a date is populated for record. I have tried making the field readonly after the current date is populated first time, but still the date gets changed automatically the next day.

 

The current Custom Calculation Script used by me in a text field is:
event.target.value = util.printd("mm/dd/yyyy", new Date());
event.target.readonly = true;

 

Can anyone provide guidance on this?

This topic has been closed for replies.
Correct answer try67

This is incorrect:

fld.display = fld.visible;

It should be:

fld.display = display.visible;

2 replies

PDF Automation Station
Community Expert
Community Expert
July 22, 2024

Put the entire script in a mouse up action in the button field like this:

var fld=this.getField("Date");

fld.value = util.printd("mm/dd/yyyy", new Date());

fld.display = display.visible;

You could also disappear the button if it is no longer needed:

event.target.display = display.hidden;

Participating Frequently
July 22, 2024

Thank you so much!

Bernd Alheit
Community Expert
Community Expert
July 22, 2024

Set the value only when the field is empty.

Participating Frequently
July 22, 2024

Thank you Bernd for you quick reply!

 

Sorry to ask this, but can you please put it in a sample code for me?

Bernd Alheit
Community Expert
Community Expert
July 22, 2024

Like this:

if (event.target.value == "") event.target.value = ...