Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Creating a Custom Calculation Script in Adobe Acrobat Pro DC

New Here ,
Nov 16, 2020 Nov 16, 2020

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

TOPICS
Acrobat SDK and JavaScript
1.5K
Translate
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 3 Correct answers

Community Expert , Nov 16, 2020 Nov 16, 2020

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

...
Translate
Community Expert , Nov 17, 2020 Nov 17, 2020

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
Community Expert , Nov 17, 2020 Nov 17, 2020

Thank you! All acknowledged.

Translate
Community Expert ,
Nov 16, 2020 Nov 16, 2020

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
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
Community Expert ,
Nov 17, 2020 Nov 17, 2020

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
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
Community Expert ,
Nov 17, 2020 Nov 17, 2020

Thank you! All acknowledged.

Translate
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 ,
Nov 17, 2020 Nov 17, 2020
LATEST

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