I am trying to create a SUMIF formula in adobe acrobat and have no idea where to begin. The code I am working with =SUMIF($F$7:$F$28,$H30,I$7:I$28). Any help of where to begin and how to finish building the script would be great.

New Here ,
Jan 18, 2018 Jan 18, 2018

Copy link to clipboard

Copied

I am trying to create a SUMIF formula in adobe acrobat and have no idea where to begin. The code I am working with =SUMIF($F$7:$F$28,$H30,I$7:I$28). Any help of where to begin and how to finish building the script would be great.

Thank you,

Ali

TOPICS
Acrobat SDK and JavaScript

Views

232

Likes

Translate

Translate

Report

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

correct answers 1 Correct Answer

Adobe Community Professional , Jan 18, 2018 Jan 18, 2018

Likes

Translate

Translate
Adobe Community Professional ,
Jan 18, 2018 Jan 18, 2018

Copy link to clipboard

Copied

Here are some articles that cover performing calculations in Acrobat:

https://acrobatusers.com/tutorials/how-to-do-not-so-simple-form-calculations

https://acrobatusers.com/tutorials/conditional-execution

Calculating field values and more

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 19, 2018 Jan 19, 2018

Copy link to clipboard

Copied

This is what I have so far:

var total = 0; 

var maxFields = 22; 

for (var i=1; i<=maxFields; i++) { 

    if (this.getField("M"+i).value==("Code1") 

          total+=Number(this.getField("TL"+i).field);  

}

event.value = total; 

"Code1" is a field within the PDF, something isn't linking. How would I get it so it SUMS all TL if M matches field "Code1"?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jan 19, 2018 Jan 19, 2018

Copy link to clipboard

Copied

LATEST

Good try   You've got a syntax error and an incorrect property

Here's the corrected code:

var total = 0;

var maxFields = 22;

for (var i=1; i<=maxFields; i++) {

    if (this.getField("M"+i).value=="Code1")

          total+=Number(this.getField("TL"+i).value);

}

event.value = total;

To see the reported errors and debug your code you need to use the Console Window. Here's a tutorial:

https://www.youtube.com/watch?v=iuFYRYezk2g&list=PLuqLmh10M1wXmHIJDqbBWVf9jU0FAtjrU&index=4

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

Likes

Translate

Translate

Report

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