Fix an Acrobat JavaScript Calculation Script That Returns No Result
Question details
The user needs to identify why a custom Acrobat form calculation script does not return a result.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- Calculating a PDF form field value with a custom JavaScript script.
- Observed behavior
- The calculation script does not produce a result.
Open the PDF in Acrobat and identify the calculated field and the input fields it references. Make sure Acrobat JavaScript is enabled under Preferences > JavaScript.
Debug the Acrobat calculation script and field references
Use the JavaScript console and form field properties to locate syntax errors, invalid references, and calculation problems.
In Acrobat, press Ctrl+J on Windows or Command+J on Mac to open the JavaScript console. Trigger the calculation and look for error messages and line numbers.
Open Prepare a form, select the calculated field, and open its Properties. On the Calculate tab, select the custom calculation script and click Edit.
Make sure field names in calls such as this.getField("Amount") are quoted and match the form field names exactly. Check parentheses, braces, operators, variable names, and the order of if and else conditions.
Ensure the calculation assigns a value to event.value. For example, after verifying that Amount and Rate are valid numeric fields, use event.value = Number(this.getField("Amount").value) * Number(this.getField("Rate").value);.
Save the script, close field properties, and enter values in the input fields. If the result is still incorrect, check the console again and review the calculation order in Prepare a form.

Edit PDFs and Office documents with WPS Office
WPS Office is a free, lightweight alternative with a familiar interface for working with PDFs and Office documents. Its format compatibility can make migration easier, but it does not debug Acrobat's custom JavaScript calculations.

Frequently Asked Questions
How can I see the error in my Acrobat calculation script?
Press Ctrl+J on Windows or Command+J on Mac to open the JavaScript console, then trigger the calculation and review any error message and line number.
Where do I edit a custom calculation script?
In Acrobat, open Prepare a form, select the calculated field, and open Properties. On the Calculate tab, select the custom calculation script and click Edit.
Why does my script fail to find a form field?
Check that the name passed to this.getField is in quotation marks and matches the actual field name exactly. You can inspect field names in Prepare a form.
Why is the result incorrect when several fields are calculated?
A calculated field may be evaluated before another field it depends on. Review the field calculation order in Prepare a form and place dependent calculations after their source calculations.
Can WPS Office debug an Acrobat JavaScript calculation?
No. Use Acrobat's JavaScript console and form field properties to troubleshoot the script. WPS Office can be used separately for everyday PDF and Office document tasks.




