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

Sum function script not updating field when variables being blank

New Here ,
Feb 07, 2018 Feb 07, 2018

Copy link to clipboard

Copied

Earlier, I asked how to hide values if the the value=0 and got the correct script to put in.

The script I used for this was:

var amount = Number(this.getField("Qty2").value) * Number(this.getField("UP2").value);

event.value = (amount==0) ? "" : amount;

However, the sum function for the "Subtotal" field is now not updating. I am using the sum function in the calculator tab. Am I suppose to put in a script now or can I still use the sum function? Please see the snapshot below. Thanks!

TOPICS
Acrobat SDK and JavaScript , Windows

Views

413

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 ,
Feb 07, 2018 Feb 07, 2018

Copy link to clipboard

Copied

Check the field calculation order. The Subtotal field needs to be calculated after the Amount field(s).

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 ,
Feb 07, 2018 Feb 07, 2018

Copy link to clipboard

Copied

Thanks!

I had to manually type in the addition of each field as the sum function doesn't do it in the correct order.

Thanks for all your help!

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 ,
Feb 07, 2018 Feb 07, 2018

Copy link to clipboard

Copied

That means you didn't solve the problem I pointed out...

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 ,
Feb 07, 2018 Feb 07, 2018

Copy link to clipboard

Copied

Sorry, I'm new to this so I don't have much experience. Can you explain what you mean?

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 ,
Feb 07, 2018 Feb 07, 2018

Copy link to clipboard

Copied

In the "Prepare form" mode in Acrobat there is a drop menu on the far left panel with an entry for setting the calculation order. You need to check this and make sure the "SubTotal" field is at the bottom of the list.

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 ,
Feb 07, 2018 Feb 07, 2018

Copy link to clipboard

Copied

Got it thank you

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 ,
Feb 07, 2018 Feb 07, 2018

Copy link to clipboard

Copied

LATEST

Sorry, far right panel.

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