Expand my Community achievements bar.

SOLVED

Hide Repeating Subform

Avatar

Level 9

I have a nested subform inside a repeating subform (Q1). I would like to be able to click a button and hide all instances of the nested subforms. It is named Subform3.Capture.PNG

I tried this script:

LPA.FormButtons.HideButtons::click - (JavaScript, client)

this.resolveNode("Q1[*].Subform3[*]").presence = "hidden";

1 Accepted Solution

Avatar

Correct answer by
Level 10

Use this if Subform3 has only one instance and if Q1 doesn't need to be specified its index(if it crashes use the second loop)

for (var i = 0; i < this.resolveNode("Q1").instanceManager.count; i++){

     this.resolveNode("Q1[" + i.toString() + "].Subform3").presence = "hidden";

}

Use this if Subform 3 has only one isntance and if Q1 need to be specified its index

for (var i = 0; i < this.resolveNode("Q1[0]").instanceManager.count; i++){

     this.resolveNode("Q1[" + i.toString() + "].Subform3").presence = "hidden";

}

Use this if Subform3 has more than one instance

for (var i = 0; i < this.resolveNode("Q1[0]").instanceManager.count; i++){

     for (var ii = 0; ii < this.resolveNode("Q1[" + i.toString() + "].Subform3").instanceManager.count; ii++){

          this.resolveNode("Q1[" + i.toString() + "].Subform3").presence = "hidden";

     }

}

View solution in original post

3 Replies

Avatar

Correct answer by
Level 10

Use this if Subform3 has only one instance and if Q1 doesn't need to be specified its index(if it crashes use the second loop)

for (var i = 0; i < this.resolveNode("Q1").instanceManager.count; i++){

     this.resolveNode("Q1[" + i.toString() + "].Subform3").presence = "hidden";

}

Use this if Subform 3 has only one isntance and if Q1 need to be specified its index

for (var i = 0; i < this.resolveNode("Q1[0]").instanceManager.count; i++){

     this.resolveNode("Q1[" + i.toString() + "].Subform3").presence = "hidden";

}

Use this if Subform3 has more than one instance

for (var i = 0; i < this.resolveNode("Q1[0]").instanceManager.count; i++){

     for (var ii = 0; ii < this.resolveNode("Q1[" + i.toString() + "].Subform3").instanceManager.count; ii++){

          this.resolveNode("Q1[" + i.toString() + "].Subform3").presence = "hidden";

     }

}

Avatar

Level 10

By the way I think that the stars --> Q1[*] you are using in your code have more chance to work in FormCalc than javascript and it must be used outside of the resolveNode also