PDF Editing Issues

How to Automatically Generate Sequential Purchase Order Numbers in Acrobat

Elise WilliamsElise Williams Nov 5, 2026 869 views

Question details

The user wants to learn how to create a PDF form in Adobe Acrobat that automatically generates sequential purchase order numbers (e.g., FY21-DDMM1) using JavaScript.

How to Automatically Generate Sequential Purchase Order Numbers in Acrobat
Product
Adobe Acrobat
Device & OS
not provided
Scenario
Creating dynamic PDF forms for purchase orders that require unique, auto-incrementing tracking numbers based on the fiscal year and current date.
Observed behavior
A method is needed to format the date and increment a sequence value reliably within the PDF, while avoiding duplication in multi-user environments.
Before you start

Ensure you have Adobe Acrobat Pro installed, as standard PDF readers cannot create or edit document-level JavaScript functions.

Solution 1Recommended

Use Document-Level JavaScript to Auto-Increment Numbers locally

Add a custom JavaScript function to your PDF to calculate the date and append a sequential number when the document is used by a single user.

Using Acrobat's built-in JavaScript engine, you can construct custom formats like 'FY21-DDMM1'. This method involves fetching the current date, formatting it, and combining it with a sequence value stored in a hidden field or document variable.

1
Prepare the PDF Form

Open your document in Adobe Acrobat Pro, go to 'Tools', and select 'Prepare Form'. Add a new Text Field where you want the Purchase Order number to appear.

2
Access Document JavaScripts

Navigate to the 'JavaScript' tool panel on the right sidebar and click 'Document JavaScripts'.

3
Write the Formatting Script

Create a new script that uses JavaScript Date methods to extract the current day and month, format them as 'DDMM', and concatenate them with your fiscal year prefix (e.g., 'FY21-').

4
Append the Sequence Value

Add logic to read the last used sequence number, increment it by 1, append it to your date string, and output the final value into your PO Number Text Field.

Use Document-Level JavaScript to Auto-Increment Numbers locally
Testing Recommended: Always thoroughly test the date format and sequence rollover behavior (e.g., what happens when the day or month changes) locally before deploying the form.

Create Auto-Sequential Purchase Orders Easily with WPS Spreadsheet

Instead of writing complex JavaScript for PDFs, you can use WPS Spreadsheet to automatically generate sequential purchase order numbers and instantly export them as professional PDF documents.

  1. 1. Design Your Template: Launch WPS Spreadsheet and create or open your Purchase Order template.
  2. 2. Enter the Sequence Formula: In your PO Number cell, enter a dynamic formula like `="FY21-" & TEXT(TODAY(),"DDMM") & ROW(A1)` to generate the base number.
  3. 3. Auto-Fill Sequences: When creating a list of POs, simply drag the cell's fill handle down to automatically generate the next sequence numbers without duplicates.
  4. 4. Export to PDF: Once your purchase order is ready, go to 'Menu' and click 'Export to PDF' to generate a final, uneditable document ready to be sent to vendors.
No coding or advanced JavaScript required for automatic numbering.Fully compatible with Microsoft Excel (.xlsx) formats and formulas.Built-in PDF converter to easily export purchase orders into fixed PDF documents.Lightweight, fast, and completely free to download and use.
microsoft office alternative - wps office

Frequently Asked Questions

Why are my sequential PDF numbers resetting every time I open the form?

If your JavaScript uses a local variable without saving it to a persistent document property, hidden field, or external file, the sequence will naturally reset to its initial value each time the PDF document is reopened.

Can I share a JavaScript-enabled PDF form with multiple users to get unique PO numbers?

No. A standalone PDF form cannot communicate with other copies of itself. To maintain a unique sequence across multiple users, you must connect the PDF to an external database or use a centralized server-side script.

What does a sample JavaScript date format look like for FY21-DDMM?

You would use JavaScript Date methods like `getDate()` and `getMonth() + 1`, pad them with leading zeros using a conditional statement, and concatenate them. For example: `var day = (d.getDate() < 10 ? '0' : '') + d.getDate();`.