• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

if then statement in text box

New Here ,
Mar 12, 2019 Mar 12, 2019

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

TOPICS
Acrobat SDK and JavaScript , Windows

Views

451

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 12, 2019 Mar 12, 2019

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 13, 2019 Mar 13, 2019

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 12, 2019 Mar 12, 2019

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;

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 13, 2019 Mar 13, 2019

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 13, 2019 Mar 13, 2019

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 =

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 12, 2019 Mar 12, 2019

Copy link to clipboard

Copied

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

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

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 13, 2019 Mar 13, 2019

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 13, 2019 Mar 13, 2019

Copy link to clipboard

Copied

LATEST

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines