Append PDF Form Field Values with JavaScript in Adobe Acrobat
Question details
Combine a work order number and a second value in a calculated PDF form field.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- A PDF form needs to append the value of the BU1 field to the work order number in the WO#1 field.
- Observed behavior
- The result field should display the combined text when both source fields contain values and update when either value changes.
Open the PDF in Adobe Acrobat and confirm that the source fields are named WO#1 and BU1 and that a separate text field exists for the result. Field names in the script must match the form exactly.
Add a custom calculation script to the result field
Use this method to combine the two field values automatically while preserving them as text.
In Acrobat, open the PDF and select All tools > Prepare a form.
Double-click the separate text field that should display the combined value, then open its Calculate tab.
Select Custom calculation script, click Edit, and enter: var WO1 = this.getField("WO#1").valueAsString; var BU1 = this.getField("BU1").valueAsString; event.value = (WO1 !== "" && BU1 !== "") ? WO1 + BU1 : "";
Close the properties dialog, save the PDF, and use Preview in Prepare a form to enter values in WO#1 and BU1. Confirm that the result field displays them together.

Work with PDFs and Office files in WPS Office
WPS Office is a free, lightweight alternative with a familiar interface for working with PDFs and Office documents. Its format compatibility makes it easy to move everyday files between suites, but it does not fix Acrobat or guarantee support for Acrobat form JavaScript.

Frequently Asked Questions
Why does the result field stay blank?
The script displays a result only when both WO#1 and BU1 have values. Check the field names in Prepare a form and make sure they match the names in the script exactly.
How can I add a separator between the two values?
In the result field's Calculate > Custom calculation script editor, replace WO1 + BU1 with WO1 + "-" + BU1 to insert a hyphen.
Will the calculation work in every PDF viewer?
No. The viewer must support Acrobat form JavaScript. Test the saved PDF in the viewer your recipients will use.
Why does the script use valueAsString?
The valueAsString property reads each field as text, so the script concatenates the values rather than treating them as numbers.




