I have created a travel expense tracking form. I have used your dynamic table to give users the ability to enter all their travel reimbursements. There are many fields, but the important ones for this questions are: expense type, payment type, total (which calculates a total based on the original charge * conversion rates).
I also have a summary sheet (which is used by the controller’s office to process the reimbursement). The sheet needs to use IF statements to SUM values based on the their answers below. My current script works to conditionally sum the first row of the tracking expense chart; however, if I add additional rows, it will not evaluate those. I think I need some sort of array formula but I don’t know what that looks like. I have been using FormCalc because I know no JavaScript.
if (form1.#subform[3].General_Expense.Item[*].expense_type == “51807 – Membership Dues/Fees” and form1.#subform[3].General_Expense.Item[*].payment_type <> “BMC Credit Card”) then Sum(form1.#subform[3].General_Expense.Item.total) endif
Form can be emailed upon request.
Given that, then you'll need to write a loop that applies this "if" statement for each individual repeated instance. This kind of complex logic is better implemented with JavaScript than FormCalc.
For example:
var sum = 0;
var aLines = form1.resolveNodes("$..General_Expense.Item[*]");
for(var i=0;i<aLines.length;i++)
{
if(aLines.item[i].expense_type.rawValue == "51807 – Membership Dues/Fees"
&& aLines.item[i].payment_type.rawValue != "BMC Credit Card")
sum += aLines.item[i].total.rawValue;
}
sum;
Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script