How to Automatically Populate PDF Form Fields from a Payroll ID
Question details
The user needs a way to automatically fill in specific PDF form fields, such as Name and Designation, based on the input of a Payroll ID.

- Product
- PDF Editor
- Device & OS
- not provided
- Scenario
- Creating dynamic PDF forms for payroll or employee records to reduce manual data entry.
- Observed behavior
- The user wants to enter a Payroll ID into a form field and have the corresponding employee's Name and Designation automatically appear in their respective text fields.
Ensure you have the exact list of Payroll IDs, Names, and Designations ready to create your lookup mapping, and verify that your PDF editor supports JavaScript for custom field calculations.
Use Custom JavaScript to Create a Lookup Mapping
Create an array or switch-case mapping within the PDF form field's custom calculation script to link Payroll IDs to specific employee data.
This approach requires basic JavaScript knowledge. By attaching a calculation script to the Name and Designation fields, the PDF will automatically read the Payroll ID field and update the relevant outputs.
Open your PDF document in your PDF editor and enter the Form Editing mode from the top toolbar.
Right-click the 'Name' or 'Designation' text field that you want to populate automatically and select 'Properties'.
Navigate to the 'Calculate' tab, select the 'Custom calculation script' radio button, and click the 'Edit' button.
Input JavaScript to evaluate the 'Payroll ID' field. For example: var id = this.getField('PayrollID').value; if(id == '123') event.value = 'John Doe'; else event.value = '';
Save your script, exit form editing mode, and type a Payroll ID into the designated field to verify the automatic population is working correctly.

Populate Text Fields Using a Drop-Down Menu
If you prefer selecting the Payroll ID from a list rather than typing it manually, you can tie a drop-down menu selection to a text field update.
Create and Edit Advanced PDF Forms with WPS Office
WPS Office provides a comprehensive PDF toolkit that allows you to effortlessly design interactive forms, insert form controls, and manage document workflows for auto-populating fields.
- 1. Open WPS PDF: Launch WPS Office and open your PDF document using the built-in PDF editor.
- 2. Enter Form Mode: Navigate to the 'Form' tab on the top ribbon to access all interactive form creation tools.
- 3. Add Form Fields: Select 'Text Field' or 'Combo Box' and click on the document where you need the fields to be placed.
- 4. Edit Properties: Double-click the newly inserted form field to adjust its name, appearance, and advanced calculation properties.

Frequently Asked Questions
Why isn't my PDF text field updating automatically after entering the Payroll ID?
Your PDF viewer may have JavaScript disabled by default for security reasons, or there might be a syntax error in your calculation script. Ensure JavaScript is enabled in your PDF reader's preferences.
Can I import a large list of Payroll IDs from Excel directly into the PDF?
Standard PDF editors usually require custom JavaScript or specific data connection setups to link external databases like Excel dynamically. For smaller lists, it is easiest to hardcode the mapping directly into the PDF calculation script.
Are PDF form calculation scripts case-sensitive?
Yes, JavaScript used in PDF forms is entirely case-sensitive. You must ensure your variable names, field names (like 'PayrollID' vs 'payrollid'), and commands match exactly.




