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

Force recalculation

New Here ,
Apr 09, 2018 Apr 09, 2018

I‘ve got a form with fields, with Subtotal and Total. The calculation order is correct, this form works perfectly.

I‘ve got another similar form that sometimes gets added to the first, with Subtotal as the last field. This works perfectly too. But when added to the first form, the Total doesn‘t work correctly across all the sheets, as the calculation order is no longer correct - the Total on the first sheet is calculated before the Subtotals on subsequent sheets.

One solution would be to stipulate that they MUST paste the extra sheets BEFORE the first sheet, then reoder them, so that Total is always calculated last. But that creates other problems.

A better solution would be to force a double recalculation whenever a subtotal is changed, using Validation. The first time would calculate all subtotals correctly, the second time would then get the correct answer in the Total. I thought this.calculateNow() should do it, or doc.calculateNow(), but this doesn‘t work. Perhaps there is a command to abandon and restart the calculation if the current field (a Subtotal field) gets changed? Can someone help me?

TOPICS
PDF forms
2.5K
Translate
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 ,
Apr 09, 2018 Apr 09, 2018
LATEST

The "calculateNow()" function does force recalculation. If it is not working for getting your field up to date, then something else is going on that is preventing it. Try running it from the console window after the other calculations have finished.

The problem may be that at the time the subtotal validation happens, the needed field values haven't yet been committed.

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

Translate
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