• Need help with customized calculation script in Ac...

# Need help with customized calculation script in Acrobat Pro

New Here ,
May 06, 2022 May 06, 2022

Copied

I've got a calculation worksheet going and have added the basic calculations to it but there is one field that requires something more complex - not even sure if it can be done but I thought I'd throw it out there. Here's a run down of the calculation that includes my field names:

fill_5 = the greater of fill_82 and fill_83 only when fill_81 is greater than \$5000, otherwise, fill_5 = fill_82

If that's not possible, another route that would serve the same purpose for me would be:

fill_83 = fill_81 x 0.06 only when fill_81 is greater than \$5000, otherwise, fill_83 = 0

*note the "0.06" is a field name

Can anyone help me out on figuring out if either of these is possible and how to script it out?

TOPICS
How to , JavaScript , PDF forms

Views

83

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Adobe Community Professional , May 06, 2022 May 06, 2022

Sure, it's possible. You can use this code as the field's custom calculation script:

``````if (Number(this.getField("fill_81").valueAsString)>5000)
event.value = Math.max(Number(this.getField("fill_82").valueAsString), Number(this.getField("fill_83").valueAsString));
else event.value = this.getField("fill_82").valueAsString;``````

Likes

3 Replies 3
May 06, 2022 May 06, 2022

Copied

Sure, it's possible. You can use this code as the field's custom calculation script:

``````if (Number(this.getField("fill_81").valueAsString)>5000)
event.value = Math.max(Number(this.getField("fill_82").valueAsString), Number(this.getField("fill_83").valueAsString));
else event.value = this.getField("fill_82").valueAsString;``````

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
New Here ,
May 09, 2022 May 09, 2022

Copied

LATEST

Woo! Thanks so much that works great!!

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
May 06, 2022 May 06, 2022

Copied

https://www.pdfscripting.com/public/How-to-Write-a-Basic-PDF-Calculation-Script.cfm

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Resources