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:
Really appreciate any help!!!
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
...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");
Thank you! All acknowledged.
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
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");
Copy link to clipboard
Copied
Thank you! All acknowledged.
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"}
}