How to Automatically Generate Sequential Purchase Order Numbers in Acrobat
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.

- 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.
Ensure you have Adobe Acrobat Pro installed, as standard PDF readers cannot create or edit document-level JavaScript functions.
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.
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.
Navigate to the 'JavaScript' tool panel on the right sidebar and click 'Document JavaScripts'.
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-').
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.

Connect to an External Database for Multi-User Sequencing
Implement a database connection or a trusted folder-level script if multiple users need to generate unique PO numbers simultaneously without conflicts.
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. Design Your Template: Launch WPS Spreadsheet and create or open your Purchase Order template.
- 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. 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. 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.

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();`.




