Using "mmddyyhm" in a PDF as a project number

New Here ,
Mar 12, 2021 Mar 12, 2021

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.

TOPICS
JavaScript

Views

64

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Most Valuable Participant ,
Mar 12, 2021 Mar 12, 2021

Copy link to clipboard

Copied

Change the second line to:

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

this.getField("UniqueNumber").value = util.printd("yymmddHHMM", d);

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 22, 2021 Mar 22, 2021

Copy link to clipboard

Copied

Thank you, that resolved my issue. I appreciate your help!

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines