Highlighted

Creating a Custom Calculation Script in Adobe Acrobat Pro DC

New Here ,
Nov 16, 2020

Copy link to clipboard

Copied

So.. I know nothing about JavaScript. Simply tooling around with PDF as a potential proposal tool.

 

I'm trying to apply operators (less than, greater than, equal to) to an existing output  "Propsal Score", that will create an output in a second box "Accountig Type". If my Value Sum from "Proposal Score" is between 0 an 50, how do I have the second text box populate:

  • "Cash Basis" if the Proposal Score is 0-10   
  • "Hybrid Basis" if the Proposal score is 11-30
  • "Accrual Basis" if the Proposal score is 31-50

Really appreciate any help!!!

Adobe Community Professional
Correct answer by ls_rbls | Adobe Community Professional

Thank you! All acknowledged.

TOPICS
Acrobat SDK and JavaScript, Comment review and collaborate PDF, Create PDFs, Edit and convert PDFs, General troubleshooting, How to, PDF forms

Views

53

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

Creating a Custom Calculation Script in Adobe Acrobat Pro DC

New Here ,
Nov 16, 2020

Copy link to clipboard

Copied

So.. I know nothing about JavaScript. Simply tooling around with PDF as a potential proposal tool.

 

I'm trying to apply operators (less than, greater than, equal to) to an existing output  "Propsal Score", that will create an output in a second box "Accountig Type". If my Value Sum from "Proposal Score" is between 0 an 50, how do I have the second text box populate:

  • "Cash Basis" if the Proposal Score is 0-10   
  • "Hybrid Basis" if the Proposal score is 11-30
  • "Accrual Basis" if the Proposal score is 31-50

Really appreciate any help!!!

Adobe Community Professional
Correct answer by ls_rbls | Adobe Community Professional

Thank you! All acknowledged.

TOPICS
Acrobat SDK and JavaScript, Comment review and collaborate PDF, Create PDFs, Edit and convert PDFs, General troubleshooting, How to, PDF forms

Views

54

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 16, 2020 0
Adobe Community Professional ,
Nov 16, 2020

Copy link to clipboard

Copied

I think you can employ an IF condition in a custom calculation script like this:

 

var propType  = this.getField("Proposal Type").valueAsString;

event.value ="";

if (propType !=="") {

if (propType >= "0" && propType <= "10") { event.value = "Cash Basis"}
if (propType >= "11" && propType <= "30") { event.value = "Hybrid Basis"}
if (propType >= "31" && propType <= "50") { event.value = "Accrual Basis"}

} 

 

I am running this script as a custom calculation script in the "Accounting Type" text box

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

Copy link to clipboard

Copied

When comparing numbers one must not place them in quotes, as that converts them to strings.

To see the difference run the following code in the JS Console:

 

console.println(100>30);
console.println("100">"30");

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 1
Adobe Community Professional ,
Nov 17, 2020

Copy link to clipboard

Copied

Thank you! All acknowledged.

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 1
New Here ,
Nov 17, 2020

Copy link to clipboard

Copied

Thank you, thank you. ls_rbls and try67.

 

I used your input, with subtle changes, and it worked!

 

var proScore  = this.getField("Proposal Score").valueAsString;

 

event.value ="";

 

if (proScore !=="") {

 

if (proScore >= 0 && proScore <= 10) { event.value = "Cash Basis"}

if (proScore >= 11 && proScore <= 30) { event.value = "Hybrid Basis"}

if (proScore >= 31 && proScore <= 50) { event.value = "Accrual Basis"}

 

}

 

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 1