How to Generate Unique Order Numbers in Interactive PDF Forms
Question details
The user wants to automatically generate a unique order number within an interactive PDF form combining a customer name field and a timestamp.

- Product
- Device & OS
- not provided
- Scenario
- Filling out an interactive PDF order form where an order number needs to be auto-populated in real-time as the fields are being completed.
- Observed behavior
- The goal is to dynamically display a generated tracking number before the document is saved or submitted, ensuring order tracking efficiency.
Ensure your PDF editor supports JavaScript and form field calculations. You will need to know the exact exact field name for the customer name to properly configure the script.
Configure a Custom Calculation Script using JavaScript
Add a custom JavaScript code to a text field to combine the customer name and a real-time timestamp into a unique order number.
Using JavaScript allows you to pull text from a designated Customer Name field and append the current date and time. While this significantly reduces duplicate numbers, keep in mind that absolute uniqueness across multiple users simultaneously requires a server-side process.
Open your interactive PDF form in a capable PDF editor and switch to the Form Editing mode to reveal form fields.
Right-click the text field designated for your Order Number and select 'Properties' from the context menu.
Navigate to the 'Calculate' tab and select the option for 'Custom calculation script'.
Click 'Edit' and enter a script that retrieves the 'Customer Name' field value and appends a formatted timestamp (e.g., combining this.getField('Customer Name').value with a Date object).
Close the properties window, exit form editing mode, and test the form by entering a name to see the order number generate instantly.

Easily Create and Fill Interactive PDF Forms with WPS Office
WPS Office provides a comprehensive suite of PDF tools, allowing you to create, edit, fill out, and manage interactive PDF forms efficiently. It's a lightweight, cost-effective alternative for handling all your daily PDF and document workflows.
- 1. Open WPS Office: Launch WPS Office and click on the 'PDF' tab to access the PDF editor.
- 2. Load your PDF Form: Open your existing PDF form or create a new one from a blank document.
- 3. Access the Form Tab: Navigate to the 'Form' tab on the top ribbon to add or edit interactive fields like Text Fields, Checkboxes, and Dropdowns.
- 4. Modify Properties: Double-click any field to modify its properties, set default values, or adjust formatting.

Frequently Asked Questions
Can I guarantee 100% unique order numbers using only PDF JavaScript?
No. While a timestamp combined with a customer name heavily reduces the chance of duplicates, absolute uniqueness requires a server-side process or database to verify and assign sequential numbers centrally.
Why isn't my order number updating automatically when I type the name?
Make sure that the 'Calculate' trigger is properly set and that your PDF reader has JavaScript enabled. Sometimes, the calculation may require moving the cursor out of the text field (losing focus) to trigger the update.
What is the best format for a timestamp in an order number?
A common and effective format is 'YYYYMMDD-HHMMSS'. This ensures the order numbers sort chronologically and includes enough granularity (down to the second) to prevent identical timestamps.
Can I hide the order number field until the form is printed?
Yes. In the field properties under the 'General' or 'Appearance' tab, you can set the form field's visibility to 'Visible but doesn't print' or 'Hidden but printable' depending on your specific needs.




