Copy link to clipboard
Copied
I've created a PDF with a field to be used as a unique project number. The filed is being populated with the date and time with this java script:
// get the current date and time
var d = new Date();
this.getField("UniqueNumber").value = util.printd("yymmddHHMM", d);
The problem I have is the date/time changing every time the PDF is opened. The goal is to use this PDF as a template that will be saved as a new copy each time it is opened. I need the date and time to be locked/frozen so when the file is reopened after saving it maintains the unique time stamp.
Copy link to clipboard
Copied
Change the second line to:
if (this.getField("UniqueNumber").valueAsString=="")
this.getField("UniqueNumber").value = util.printd("yymmddHHMM", d);
Copy link to clipboard
Copied
Thank you, that resolved my issue. I appreciate your help!