• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

248

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
Community Expert ,
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);

Votes

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

LATEST

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

Votes

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