Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Adobe Summit 2023 [19th to 23rd March, Las Vegas and Virtual] | Complete AEM Session & Lab list

Creating Repeating Subform For Loop


Level 1

Need some help creating a for loop in FormCalc.

If text entered in “myField” and “Inv” fields are the same, sum amounts ”amt” in a repeating
subform.  This concept seems to work ok, in javascript using static subforms,

e.g, subform0, subform1, subform3, etc... However, can’t get it to work with repeating subforms.


FormCalc version

var amt = Ref(subform1[*].myAmounts.nodes)

var inv = Ref(subform1[*].myInventory.nodes)

var i

for i=0 upto (i <= amt.length-1) do

if (myField == inv.item(i)) then

$ = Sum(amt)




JavaScript version -  Works with static subforms, but not with repeating subforms.

var amt = xfa.resolveNodes("subform1[*].myAmounts");

var inv = xfa.resolveNodes("subform1[*].myInventory");

var sum = 0;

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

if (myField.rawValue == inv.item(i).rawValue) {

sum = sum + amt.item(i).rawValue;


     this.rawValue = sum;


0 Replies