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;
Copy link to clipboard
Copied
So what's the issue?
Copy link to clipboard
Copied
Sorry about that. It won't subtract the Cash Advance field.
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.
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.
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.
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?
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.
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.
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.
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.
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
You don't need Javascript for the calculation.
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 ?
Copy link to clipboard
Copied
Yes.
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.
Copy link to clipboard
Copied
https://acrobatusers.com/tutorials/changing-order-of-field-calculations-using-acrobat-dc/
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.
Copy link to clipboard
Copied
The forum software has added %C2%A0 at the end of the link. Remove this and the link will work.
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.