Expand my Community achievements bar.

July 31st AEM Gems Webinar: Elevate your AEM development to master the integration of private GitHub repositories within AEM Cloud Manager.

Loop Through Subform Instances


Level 1

I'm very new to Javascripts and Livecycle,

I have 4 fields (field1.rawValue, field2.rawValue, field3.rawValue & field4.rawValue wrapped in Subform1.  I'm attempting to sum values entered in fields 1, 2, & 3 into field 4 with the following script.

var myFields = field1.field2.field3.resolveNodes("Subform1[*]");

var sum = 0.0

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

sum += myFields.item(i).field4.rawValue;


this.rawValue = sum;

When a new instance is added field4(1) should be the sum of field4(0) + field(1) + field2(1) + field3(1).


2 Replies


Level 4

Hey all!

The blog was extremely helpful!  Does anyone know how to loop through more than one field in a subform?

I am trying to create code where we check for multiple empty fields, looping through the subforms.

Any ideas?