Skip to main content
Henry.Ong
Inspiring
April 1, 2019
Question

Is there a way to automatically pre-fill a field in a fillable PDF with a sequential number?

  • April 1, 2019
  • 2 replies
  • 4897 views

Good day!

I am creating a fillable PDF form. In the form there is a field that I need to automatically pre-fill with a sequential number based on the last used number.

Example:

The Invoice Number field from previous PDF form is "INV0011".

I want that the next time I open the PDF form, the Invoice Number field to pre-populate "INV0012" which is the next number from the previous form. I plan to set this field as read only so the value cannot be change.

I would also want a some kind of a "Commit" button so the Invoice Number generated can be marked as use so when the form is open again it would know that a new Invoice Number needs to be generated. What would be the script for this "Commit" button?

Thanks in advance!

This topic has been closed for replies.

2 replies

Henry.Ong
Henry.OngAuthor
Inspiring
April 2, 2019

If generating the next sequential number from the previously created Invoice is really a challenge, can a unique number then be generated using the date and time up to the millisecond?

try67
Community Expert
Community Expert
April 2, 2019

Yes, that is much easier to do.

Basically, you can achieve it with the following code, used as a doc-level script:

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

It will populate a text field called "ID" with the time-stamp of the moment the file is opened.

Henry.Ong
Henry.OngAuthor
Inspiring
April 2, 2019

Thanks Try67! This is the first time I will be using the doc-level script.

How do I add the script you have provided in the doc-level script? And where can I find the doc-level script?

Eric Dumas
Community Expert
Community Expert
April 1, 2019

Hi,

This is a common issue. You will need to explain where is that form taken from and stored.

It needs a database (list) to know which is the next number available and once allocated, to lock it so other forms don't use it.

I have used SharePoint (with massive difficulties) there might be other systems that might be easier.

Henry.Ong
Henry.OngAuthor
Inspiring
April 1, 2019

Thank you Eric for sharing your experience on the issue.