Skip to main content
Participant
March 12, 2019
Question

if then statement in text box

  • March 12, 2019
  • 3 replies
  • 746 views

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

This topic has been closed for replies.

3 replies

Thom Parker
Community Expert
Community Expert
March 12, 2019

And see this article on using the "if" statement.

https://acrobatusers.com/tutorials/conditional-execution

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Participant
March 13, 2019

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)))

try67
Community Expert
Community Expert
March 13, 2019

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.

Thom Parker
Community Expert
Community Expert
March 12, 2019

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;

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Participant
March 13, 2019

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.

Legend
March 12, 2019

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.

Participant
March 13, 2019

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.