Copy link to clipboard
Copied
I have the following fields:
"New Construction or Addition" (let's call it Field 1)
"Undefined_2" (let's call it Field 2)
When someone puts a whole number into Field 1 I need that muliplied by .60 and the result will show up in Field 2 as an amount with two decimal places. However, if Field 2 is less than 600 then Field 2 needs to then say 600 with no decimal places.
I am very new to scripts so any help would be much appreciated.
Thank you!
Copy link to clipboard
Copied
Try this as custom calculation script of field 2:
var f1 = this.getField("New Construction or Addition").value;
if (/^[1-9]\d*$/.test(f1)) {
var num = Number(f1);
var result = num * 0.60;
if (result < 600) {
event.value = 600;}
else {
event.value = result.toFixed(2);}}
else {
event.value = "";}
Copy link to clipboard
Copied
Thanks, that worked! However, I also have a line below that that needs to be the sum of this final value plus some others. When I tell this sum line to add the sum of field 2 it always shows it as 600 even if the resulting number is higher than 600. Any thoughts?
Copy link to clipboard
Copied
Actually the sum line I have below is acting differently than what I said. If the amount in field 1 is 1004 then field 2 results in 602.40 which is correct. But when I create a field below that takes the sum of field 2 it lists it as 601.80. Any ideas why?
Copy link to clipboard
Copied
Can you share file?
Copy link to clipboard
Copied
Copy link to clipboard
Copied
You have issue with field calculation order, undefined_8 field should be under undefined_2 field.
To change field calculation order in old acrobat:
Select 'Prepare form' tool, click 'More' then 'Set field calculation order'.
In new Acrobat:
Select 'Prepare form' tool, click on the 3 dots (the ones where say 'fields') and select 'Set field calculation order'.
Copy link to clipboard
Copied
Thanks! That fixed it.
Copy link to clipboard
Copied
Find more inspiration, events, and resources on the new Adobe Community
Explore Now