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

Manipulate repeating subforms

Avatar

Level 2

Lets say I have a subform that has an another subform in it. Both subforms are repeating and can repeat numerous times.

The structure would be something like this:

Subform[0]

   SmallSubform[0]

            Field1

            Field2

   SmallSubform[1]

            Field1

            Field2

   SmallSubform[2]

            Field1

            Field2

Subform[1]

   SmallSubform[0]

            Field1

            Field2

   SmallSubform[1]

            Field1

            Field2

Subform[2]

   SmallSubform[0]

            Field1

            Field2

Does anyone have an idea how to loop all of this to check if Field1 and Field2 is filled out? The twist is that Field1 should be checked only if its presents is set to visible.

1 Reply

Avatar

Level 10

Hi,

Try something like;

var somethingMissing = false;

var subformList = Page1.resolveNodes("Subform[*]");

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

{

    var subformItem = subformList.item(i);

    var smallSubformList = subformItem.resolveNodes("SmallSubform[*]");

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

    {

        var smallSubformItem = smallSubformList.item(i);

        if ((smallSubformItem.Field1.isNull && smallSubformItem.Field1.presence == "visible") ||

            smallSubformItem.Field2.isNull)

        {

            somethingMissing = true;

        }

    }

}

if (somethingMissing)

{

    app.alert("something missing");

}

Regards

Bruce