Skip to main content
Inspiring
March 10, 2018
Answered

Unique number to the form each time it is saved?

  • March 10, 2018
  • 3 replies
  • 1160 views

Is it possible to format a PDF to assign a unique number to the form each time it is saved?

I want to develop a form that my staff can use as a purchase order and need it to have a unique number each time the form is filled out and submitted/saved.

This topic has been closed for replies.
Correct answer try67

Sure. One option is to use a time-stamp, which is not just unique but also allows you to pinpoint the exact moment the file was saved.

Create a read-only text field called "ID" and then enter this code under Tools - JavaScripts - Set Document Actions - Document Will Save:

this.getField("ID").value = new Date().getTime();

It will generate a 13-digit number and assign it to the field.

If you want to convert that number to a Date object you can do it like this, later on:

new Date(this.getField("ID").value)

3 replies

nikihAuthor
Inspiring
March 12, 2018

Thank you so much!  Now my question is...how to I assign that to my text field? and how can I test it to see if it's working as I intend?

JR Boulay
Community Expert
Community Expert
March 10, 2018

You can use the "DocID" too: Acrobat DC SDK Documentation

Acrobate du PDF, InDesigner et Photoshopographe
try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
March 10, 2018

Sure. One option is to use a time-stamp, which is not just unique but also allows you to pinpoint the exact moment the file was saved.

Create a read-only text field called "ID" and then enter this code under Tools - JavaScripts - Set Document Actions - Document Will Save:

this.getField("ID").value = new Date().getTime();

It will generate a 13-digit number and assign it to the field.

If you want to convert that number to a Date object you can do it like this, later on:

new Date(this.getField("ID").value)

nikihAuthor
Inspiring
March 14, 2018

Hello!  thank you so much for these instructions!  After following them, I am not able to "assign" the java script to my ID field.  Can you help me with that?

try67
Community Expert
Community Expert
March 14, 2018

You should not apply it to the field. You should place it where I specified.