Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

summarize category values

Avatar

Level 2

Hi, working with LiveCycle ES2 9. a Dynamic form with two tables. An expanding details table with 9 fields, two of the important ones I want to summarize in another summary table are DropDownList1 field with possible 6 choices and the BudgetCost field.

For each drop down list item, I would like to summarize the year to date spending on each category.

there are six possible drop down choices

Maintenance

Patrol

Small Tools

Vehicle Fuel

Office Supplies

Other Expenses

In the summary table, I have a cell for each category, and then a numeric field where I put a code (For some reason I cant copy and paste here). I have tried many different codes from this site in both formcalc and javascript, but cant get any to work.

If there is any suggestions for a new code to put in that might work on the calculate event of the numeric field, please let me know.

Thanks in advance

J

Further to this, both tables are on separate subforms, but on the same page.

3 Replies

Avatar

Level 2

Here is the code I am trying. It does not work anywhere I place it.

Would really appreciate if anyone can look it up for me and provide suggestions. It seems so simple, But I cant get it to work.

What I am trying to do is summarize the category totals based on the dropdownlist1 dollar amounts, into a separate table, which is located in a different subform.

Here is what I have so far for a code, derived from this site.

var nTotal = 0;

for (var i=0; i < DetailsTable.DetailRow.count; i++){

     if (xfa.resolveNode("DetailsTable.DetailRow[" + i + "].DropDownList1").rawValue == 1){

          nTotal += this;

     }

}

this.resolveNode("HeaderSubform.SummaryTable.Row1.NumericField5").rawValue = nTotal;

This is placed on the exit event of the budgetcost field in the details table.

J

Avatar

Level 2

Some success here now with the following code in the exit event of the BudgetCost field of the detail table.

// Getting the count of number of rows repeated

var numberOfRows = DetailTableSubform.DetailsTable.DetailRow.instanceManager.count;

//final total initialization

var total = 0;

for (var i=0; i<numberOfRows; i++){

// checking category is selected or not

          if( xfa.resolveNode("DetailTableSubform.DetailsTable.DetailRow["+i+"].DropDownList1") != null &&               xfa.resolveNode("DetailTableSubform.DetailsTable.DetailRow["+i+"].DropDownList1").rawValue != null  ){

// getting the category values

          var categoryValue = xfa.resolveNode("DetailTableSubform.DetailsTable.DetailRow["+i+"].DropDownList1").rawValue;

// Matching the category values with "A"

          if (categoryValue == "Maintenance"){

// Summing the total based on the "A" Category

               total += xfa.resolveNode("DetailTableSubform.DetailsTable.DetailRow[" + i + "].BudgetCost").rawValue;

          }

     }

}
this.resolveNode("HeaderSubform.SummaryTable.Row1.NumericField5").rawValue = total

However, even when I preview and test the details, with maintenance selected in row 1, input "500" into the budget cost and exit, the calculation above returns a "0" now instead of the 500 that it should.

What am I doing wrong?

Avatar

Level 2

I got it!!

I had to change the test value to "1" instead of the "Maintenance" awesome!.

now to try and add else if statements for the rest of the possible values. Help me with that please?

Thanks,

J