Highlighted

Custom Calculation Script If Then Statement

New Here ,
Nov 17, 2020

Copy link to clipboard

Copied

I am new to calculating in PDF Forms and am fumbling throuth this. I have a sales sheet that our team uses to track outbound sales and inbound sales. Some of the sales are to new accounts. I am trying to figure out how to put the following into a script that will do what I want.

 

Goal: If the New column is not blank then the total should be reflected in the Amount field indicated below. If there are multiple "New" marked in the New column return the sum of these totals in the Amount Field.

 

I hope this makes sense. I have attached an example of the form.Example Spreadsheet.JPG

TOPICS
How to, PDF forms

Views

58

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

Custom Calculation Script If Then Statement

New Here ,
Nov 17, 2020

Copy link to clipboard

Copied

I am new to calculating in PDF Forms and am fumbling throuth this. I have a sales sheet that our team uses to track outbound sales and inbound sales. Some of the sales are to new accounts. I am trying to figure out how to put the following into a script that will do what I want.

 

Goal: If the New column is not blank then the total should be reflected in the Amount field indicated below. If there are multiple "New" marked in the New column return the sum of these totals in the Amount Field.

 

I hope this makes sense. I have attached an example of the form.Example Spreadsheet.JPG

TOPICS
How to, PDF forms

Views

59

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
Nov 17, 2020 0
Most Valuable Participant ,
Nov 17, 2020

Copy link to clipboard

Copied

Let's say the fields are named New1 to New20 and Total1 to Total20. You can then use this code as the custom calculation script of the Amount field:

 

var totalNew = 0;

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

if (this.getField("New"+i).valueAsString!="Off")

     totalNew+=Number(this.getField("Total"+i).valueAsString);
}

event.value = total;

 

(I assume the New fields are check-boxes, not text fields...)

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
Reply
Loading...
Nov 17, 2020 0
New Here ,
Nov 17, 2020

Copy link to clipboard

Copied

Thank you for the reply. The fields are actually text fields not check boxes. Is there an adjustment that can be made to your code to make the text fields work in the calculation or should I cahnge them all to checkboxes?

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
Reply
Loading...
Nov 17, 2020 0
try67 LATEST
Most Valuable Participant ,
Nov 17, 2020

Copy link to clipboard

Copied

Changing the field type is tricky. If you want you can simply change this part of the code:

this.getField("New"+i).valueAsString!="Off"

To:

this.getField("New"+i).valueAsString!=""

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
Reply
Loading...
Nov 17, 2020 0
Adobe Community Professional ,
Nov 17, 2020

Copy link to clipboard

Copied

This article will explain how it works:

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

 

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
Reply
Loading...
Nov 17, 2020 0