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.

Having troubles adding hidden fields, using a variable from data connection?

Avatar

Level 1

Assuming my Data Connection is setup properly how could I use that data to add up a sum of records?

This is what I Have but have had no luck:

var cRecordii = xfa.record.nodes.item(nIndex);

  var oLoan = xfa.resolveNode("oLoan");
  var hForm = xfa.resolveNode("hTitle");
  var cCurrentBalance = null;
 
  oLoan.resolveNode("aggCalc").rawValue = 0;
  oLoan.resolveNode("aggCalc2").rawValue = 0;
 
  for (var nColIndex = 0; nColIndex < cRecordii.nodes.length; nColIndex++){
  
   switch(cRecordii.nodes.item(nColIndex).name) {
   
    case "CurrentBalance": cCurrentBalance = cRecordii.nodes.item(nColIndex); break;
    default: break;
   }
   xfa.host.messageBox("Testing" + " | " + oLoan.resolveNode("aggCalc").rawValue + " | " + oLoan.resolveNode("aggCalc2").rawValue + " | " + oLoan.resolveNode("aggTotal").rawValue);
   oLoan.resolveNode("aggCalc2").rawValue = oLoan.resolveNode("aggCalc").rawValue;
   oLoan.resolveNode("aggCalc").rawValue = cCurrentBalance.value;       
   oLoan.resolveNode("aggTotal").rawValue = oLoan.resolveNode("aggCalc2").rawValue + oLoan.resolveNode("aggCalc").rawValue;
  }
   
  oLoan.resolveNode("tAggregate").rawValue = oLoan.resolveNode("aggTotal").rawValue;

Orginally I tried to have cCurrentBalance = cCurrentBalance + cRecordii.nodes.item(nColIndex); but I was told this cannot work like this. I would have to use hidden fields so I tried to assign the cCurrentBalance.value to a hidden numeric field and then add those together to get a "running total" but it is still getting an error. what am I missing?

0 Replies