Use a Modified Rating in an Acrobat PDF Calculation
Question details
Use a modified rating in a PDF form calculation when it has a value, and otherwise use the original competency rating.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- A weighted competency score should use a modified rating when one is entered, including when the value is zero.
- Observed behavior
- The calculated score should multiply the modified rating by the weight when present, or multiply the original rating by the weight when the modified field is empty.
In Acrobat, open the PDF and check the exact field names for the modified rating, original rating, weight, and calculated result. The example below assumes the weight is entered as a decimal, such as 0.25 for 25%.
Add a custom calculation script to the result field
Use this approach when simplified field notation cannot express the conditional choice between ratings.
In Acrobat, open the PDF and select All tools > Prepare a form. Double-click the calculated result field to open its Properties.
On the Calculate tab, select Custom calculation script and click Edit. Replace the three example field names with your exact field names, then enter: var modified = this.getField("ModifiedRating").valueAsString; var original = this.getField("OriginalRating").valueAsString; var weight = this.getField("Weight").valueAsString; modified = modified.replace(/^\s+|\s+$/g, ""); original = original.replace(/^\s+|\s+$/g, ""); weight = weight.replace(/^\s+|\s+$/g, ""); var rating = modified !== "" ? modified : original; if (rating !== "" && weight !== "" && isFinite(Number(rating)) && isFinite(Number(weight))) { event.value = Number(rating) * Number(weight); } else { event.value = ""; }
In Prepare a form, open the form options menu and choose Set field calculation order. Place any fields that calculate the ratings or weight before the result field, and place any totals that use the result after it.
Close form editing and enter a modified rating to check the result. Clear it to test the original rating, then enter 0 as the modified rating to confirm that zero is used rather than treated as empty.

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 support helps you move existing files into your workflow, though it does not fix or guarantee execution of Acrobat-specific form scripts.

Frequently Asked Questions
Will a modified rating of zero be used?
Yes. The script checks whether the trimmed field text is empty, so a value of 0 is used in the calculation rather than triggering the original-rating fallback.
What happens if the modified rating contains invalid text?
The example leaves the result blank when the selected rating is not numeric. It falls back to the original rating only when the modified field is empty.
How do I find the correct field names?
In Acrobat, select All tools > Prepare a form and open each field's Properties. Use the exact field name shown in the General tab in the script.
Why does the result not update in the expected order?
In Prepare a form, choose Set field calculation order from the form options menu. Ensure calculated source fields come before the result and any dependent totals come after it.




