Custom Calculation, Script Help
Copy link to clipboard
Copied
I need help with formulating a custom script for the total precentage discount for section C. (Currently shown as 1234321%). Please help. I cannot figure out the correct order.
Copy link to clipboard
Copied
What script does you use?
Copy link to clipboard
Copied
I am working in the custom calculation script within Acrobat.
Copy link to clipboard
Copied
What script does you use?
Copy link to clipboard
Copied
Did you set the field as having the Percentage option selected in the Format tab? If so, the value needs to be between 0 (0%) and 1 (100%). I would recommend switching to the Number format, instead.
Copy link to clipboard
Copied
I do have this set as a Number field.
Would you be willing to look at the document?
Copy link to clipboard
Copied
Sure, but this field has no calculation associated with it...
Copy link to clipboard
Copied
Use this code:
var salePrice = Number(this.getField("Sale Price").valueAsString);
var listPrice = Number(this.getField("List Price").valueAsString);
if (listPrice==0) event.value = "";
else event.value = (1 - (salePrice / listPrice)) *100;
Copy link to clipboard
Copied
And set the field's Format to Number (with 2 decimals).

