Skip to main content
Participant
Nov 16, 2020 11:53 PM UTC
Answered

Creating a Custom Calculation Script in Adobe Acrobat Pro DC

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!!!

This topic is closed to new replies. Start a new post to keep the conversation going.
ls_rbls
ls_rblsCorrect answer
Community Expert
Nov 17, 2020 2:16 PM UTC

Thank you! All acknowledged.

Technical Generalist

4 replies

Participant
Nov 17, 2020 3:57 PM UTC

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"}

 

}

 

Translate
ls_rbls
Community Expert
Community Expert
Nov 17, 2020 12:43 AM UTC

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

Translate
Technical Generalist
try67
Community Expert
Community Expert
Nov 17, 2020 9:58 AM UTC

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");

Translate
ls_rbls
Community Expert
ls_rblsCommunity ExpertCorrect answer
Community Expert
Nov 17, 2020 2:16 PM UTC

Thank you! All acknowledged.

Translate
Technical Generalist