Copy link to clipboard
Copied
I've got a calculation worksheet going and have added the basic calculations to it but there is one field that requires something more complex - not even sure if it can be done but I thought I'd throw it out there. Here's a run down of the calculation that includes my field names:
fill_5 = the greater of fill_82 and fill_83 only when fill_81 is greater than $5000, otherwise, fill_5 = fill_82
If that's not possible, another route that would serve the same purpose for me would be:
fill_83 = fill_81 x 0.06 only when fill_81 is greater than $5000, otherwise, fill_83 = 0
*note the "0.06" is a field name
Can anyone help me out on figuring out if either of these is possible and how to script it out?
Sure, it's possible. You can use this code as the field's custom calculation script:
if (Number(this.getField("fill_81").valueAsString)>5000)
event.value = Math.max(Number(this.getField("fill_82").valueAsString), Number(this.getField("fill_83").valueAsString));
else event.value = this.getField("fill_82").valueAsString;
Copy link to clipboard
Copied
Sure, it's possible. You can use this code as the field's custom calculation script:
if (Number(this.getField("fill_81").valueAsString)>5000)
event.value = Math.max(Number(this.getField("fill_82").valueAsString), Number(this.getField("fill_83").valueAsString));
else event.value = this.getField("fill_82").valueAsString;
Copy link to clipboard
Copied
Woo! Thanks so much that works great!!
Copy link to clipboard
Copied
You'll find this article helpful:
https://www.pdfscripting.com/public/How-to-Write-a-Basic-PDF-Calculation-Script.cfm