How to Add a Sequential Tracking Number to an Acrobat PDF Form
Question details
The user needs to automatically generate and assign sequential tracking numbers to a PDF form while ensuring the assigned number is preserved in saved copies.

- Product
- Adobe Acrobat PDF
- Device & OS
- not provided
- Scenario
- Creating a dynamic PDF form that requires unique, auto-incrementing tracking numbers (e.g., invoices, receipts, or application forms) for record-keeping.
- Observed behavior
- The PDF form currently lacks a built-in mechanism to automatically increment tracking numbers each time a new copy is generated and saved.
Ensure that your PDF form already includes a designated text field to display the tracking number, and that you have access to the JavaScript editing tools in your PDF application.
Use Document JavaScript to Generate Sequential Numbers
You can add a custom JavaScript function at the document level to automatically initialize and increment the tracking number each time the form is used.
By leveraging Document JavaScript, the PDF can automatically calculate the next sequential number based on the current field value. This ensures each saved copy receives a unique tracking identifier.
Open your PDF form in Adobe Acrobat or your preferred advanced PDF editor, and navigate to the Document JavaScripts settings.
In the script name field, enter an unused name for your script, such as 'init', and click the 'Add' button.
When the JavaScript editor window opens, highlight and delete the default generated function definition so the window is completely blank.
Add your custom tracking-number script. The script should initialize your specific text field to a starting number (like 0001) and use the command util.printf("%04d", Number(f.value) + 1) to generate the subsequent number.
Save the PDF document. The script will now execute and preserve the newly generated sequential number in your saved copies.

Manage and Edit PDF Forms with WPS Office
WPS Office provides a comprehensive PDF editor that allows you to easily view, fill out, and manage interactive PDF forms while supporting a wide range of document features.
- 1. Open WPS Office: Launch the WPS Office application on your device and click on the 'PDF' tab from the home screen.
- 2. Load Your Form: Open your interactive PDF document that contains the tracking number fields.
- 3. Fill and Edit: Navigate to the 'Form' tab or simply click on the text fields to input and review your data.
- 4. Save Your Copy: Click the 'Save' or 'Save As' button to secure your form entries and preserve the generated tracking numbers.

Frequently Asked Questions
Why is the sequential tracking number not updating when I open the PDF?
If the number fails to update, your PDF viewer may be blocking JavaScript execution for security reasons. Ensure you are using a robust PDF editor that supports Document JavaScript, and check your software's security preferences to allow scripts.
Can I change the starting tracking number to something other than 0001?
Yes. You can modify the initialization value within your Document JavaScript code. Simply change the starting variable in the script to your desired number before saving the form for the very first time.
How do I remove the sequential tracking number script if I no longer need it?
To remove the script, navigate back to the Document JavaScripts menu in your PDF editor, select the script name (e.g., 'init') from the list, and click the 'Delete' button. Save the PDF file to apply the changes.
Does this JavaScript method work on mobile PDF readers?
Most mobile PDF readers have limited or no support for complex Document JavaScript. For the script to accurately read the field value and calculate the next tracking number, the form should ideally be opened and saved on a desktop PDF application.




