Copy link to clipboard
Copied
I have a rather intense PDF form we are creating as a Purchase Request.
I need an if then statement for the Line Item Adjustments total. I need it to NOT calculate anything unless there has been an actual change.
Columns are as follows:
QTY Ordered
Unit Cost
Total Cost
QTY Change
Actual Unit Cost
Line Item Adjustment
I have a calculation for the of the Total costs of the initial order. What I need now is to calculate the adjusted costs.
If QTY Change is blank, then return no result
If QTY Change has a number in it, then return total of the Line Adjustments minus the Original Amount
Copy link to clipboard
Copied
If you have a calculation it is performed every time any field changes without fail. But I don't understand why you would want to only do a calculation if something changes, since the result must be the same if nothing has changed.
Please show us your current JavaScript code, for each one identifying the action and field it applies to.
Copy link to clipboard
Copied
Thank your or your reply. Unfortunately I do not know how to write JavaScript so I have no formula I can share with you. I am trying to learn.
Copy link to clipboard
Copied
There is a very easy way to block a calculation.
Set event.rc = false;
When event.rc is false, Acrobat ignores the calculation result, i.e. the value of event.value;
Copy link to clipboard
Copied
Thank you for the information. Unfortunately I have zero clue how to write a full Java script. It was only while taking some tutorials that I discovered it could be done. I don't really understand the tutorial you shared.
Copy link to clipboard
Copied
Does this look like a start of anything:
var n = this.getField ("LineAdjustment1").value;
is (n,0) {event.rc=false; }
else if (n>0) {event.value =
Copy link to clipboard
Copied
And see this article on using the "if" statement.
https://acrobatusers.com/tutorials/conditional-execution
Copy link to clipboard
Copied
I think the easiest thing may be to add another column and build a Java Script for the IF statement
=IF(G2=0,"",(SUM(G2-D2)))
Copy link to clipboard
Copied
There's no built-in SUM command in JavaScript. Either create a field that has a calculated value that is the sum of all of these fields, or do it directly in your code.