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

Simple calculation

New Here ,
Feb 28, 2020 Feb 28, 2020

Copy link to clipboard

Copied

I think this is a simple fix but I can't figure it out.  I have an expense form that I total the different rows into a column.  Then I am adding all the totals up but before the total I need to subtract a field amount (cash advance amount).  This is the formula that I used in the Total field to add the fields and subtract the Cash Advance Amount.

 

var MT = this.getField("MilageTotal").value;
var Brkfst = this.getField("BrkFstTotal").value;
var Lnch = this.getField("LunchTotal").value;
var Dnr = this.getField("DnrTotal").value;
var Htl = this.getField("HtlTotal").value;
var Auto = this.getField("AutoTotal").value;
var Prking = this.getField("PrkingTotal").value;
var Misc = this.getField("MiscTotal").value;
var CashAdv = this.getField("CashAdvAmount_2").value;


event.value = MT + Brkfst + Lnch + Dnr + Htl + Auto + Prking + Misc - CashAdv;

 

TOPICS
PDF forms

Views

1.1K

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 28, 2020 Feb 28, 2020

Copy link to clipboard

Copied

So what's the issue?

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 28, 2020 Feb 28, 2020

Copy link to clipboard

Copied

Sorry about that.  It won't subtract the Cash Advance field.

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 28, 2020 Feb 28, 2020

Copy link to clipboard

Copied

Does that field have a calculated value? If so, check the fields calculation order.

Also, check the JS Console for errors after you change the value of any field.

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 03, 2020 Mar 03, 2020

Copy link to clipboard

Copied

That is the only calculation in that field.  I am trying sum up all the total columns but I need to subtract the Cash Advance Amount from it if there was an advance.  This picture might help better.  I couldn't remember how to download a copy of the PDF for you work on.

 

Formula.JPG

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 03, 2020 Mar 03, 2020

Copy link to clipboard

Copied

You can attach it to the original message using the tiny paperclip icon at the bottom when you edit it, or upload it to a file-sharing website (like Dropbox, Google Drive, Adobe Cloud, etc.), generate a share link and then post it here.

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 03, 2020 Mar 03, 2020

Copy link to clipboard

Copied

It's not the calculation order in the field, it's the order of calculations for all fields on the form. 

So does it add up all the other fields? What happens when a value is changed in one of the other fields. Does the total update correctly?

 

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 04, 2020 Mar 04, 2020

Copy link to clipboard

Copied

I have the document stored in the Adobe Document Cloud, this is the link, I believe you should have access to it.

 

https://documentcloud.adobe.com/link/track?uri=urn%3Aaaid%3Ascds%3AUS%3A4dbdc267-edcc-4451-b98b-74e5...

 

Thom,  Answering  your question, yes there are calculations in all the total fields at the end of each row.  All they are doing a SUM of the row.  Then the Total field at the bottom is doing a SUM of all those total fields but I need to subtract that Cash Advance field from that total.

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 04, 2020 Mar 04, 2020

Copy link to clipboard

Copied

Yes, you have errors in the fields calculation order. For example, CashAdvAmount_2 is calculated after the Total field. Hence the strange results you're seeing.

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 08, 2020 Mar 08, 2020

Copy link to clipboard

Copied

Can you explain a little more?  I have the Total field listed after the CashAdvTotal_2 field in the tab order so I thought that would determine the order of calculations.  What would fix this?  thanks.

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 08, 2020 Mar 08, 2020

Copy link to clipboard

Copied

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 08, 2020 Mar 08, 2020

Copy link to clipboard

Copied

Thanks for the link.  I went into to check the order and the Total field is the last field doing calculations.

 

Is it possible you can just show me what the java script should be?

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 08, 2020 Mar 08, 2020

Copy link to clipboard

Copied

You don't need Javascript for the calculation.

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 08, 2020 Mar 08, 2020

Copy link to clipboard

Copied

So do I just do the calculation in the Simplified field of the Total field?  What would that look like?  I tried that earlier and it didn't seem to take so I looked into the java script part.

 

Would it be

Field + Field + Field - Field  ?

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 08, 2020 Mar 08, 2020

Copy link to clipboard

Copied

Yes.

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
LEGEND ,
Mar 08, 2020 Mar 08, 2020

Copy link to clipboard

Copied

Using the Simplified Filed Notation might not prevent the error in the calculation order, so you still may need to check that. The only way to avoid this error is to create the calculation script in a single field to perform all the calculations in the form and them remove the individual form field calculations from the other fields.

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 09, 2020 Mar 09, 2020

Copy link to clipboard

Copied

https://acrobatusers.com/tutorials/changing-order-of-field-calculations-using-acrobat-dc/ 

Not Found

The requested URL was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

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 09, 2020 Mar 09, 2020

Copy link to clipboard

Copied

LATEST

The forum software has added %C2%A0 at the end of the link. Remove this and the link will work.

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 09, 2020 Mar 09, 2020

Copy link to clipboard

Copied

The foolowing line gives an error:
var Lnch = this.getField("LunchTotal").value;

 

The field "LunchTotal" doesn't exists in your form.

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