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.

Total calculation for repeating item

Avatar

Former Community Member

I want to calculate the total for a field of repeating item, from the Level Scripting Support, the resolveNodes is supported in mobile HTML form. But after getting the repeating object using resolveNodes, how can we get the length of the object for calculating.

I used the objs.length but it is undefined. Here are the my script as example:

var objs = expenses.expensesWrapper.resolveNodes("expenseRow[*]");

xfa.host.messageBox(objs,"",0,0);

xfa.host.messageBox(objs.length,"",0,0);

var sum = 0.0;

for (var i = 0; i < objs.length; i++){

    sum += objs.item(i).total.rawValue;

}

expenses.total.subTotal.rawValue = sum;

1 Reply

Avatar

Former Community Member

OK, I found a resolve for this total calculation functionality in both PDF and HTML forms, I used the following scripts:

var len = expenses.expensesWrapper._expenseRow.count;

var sum = 0.0;

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

    sum += xfa.resolveNode("expenses.expensesWrapper.expenseRow[" + i + "].total").rawValue;

}

expenses.total.subTotal.rawValue = sum;