Expand my Community achievements bar.

Code on button needs to work throughout all instances


Former Community Member

I have a subform with an 'ADD' button and a 'HIDE' button.

The 'ADD' button adds an instance of the subform.

The 'HIDE' button unhides a white box which makes the ADD button go invisible. Both buttons travel with the new instance.

When I ADD an instance of the subform and then go to the new page and try to HIDE the new ADD button it does not work.

I assume it is because I am unhiding the whitebox by name and once it is repeated the name changes.

Question: How can I have code within an instanced subform that works regardless of it's name?
4 Replies


Former Community Member
If I read things correctly, both buttons and the white box are all in the subform. If so, then script in the hide button referencing the white button by name (relative) would be referencing that instance. If you are using a fully qualified reference without a .all.item(x) in there, then you would be referencing the first one. You could test that by clicking the hide on an added instance and the box appearing in the first instance.

Another possible issue might be that the white box is appearing, but is behind the button on the later instances. You can solve that by hiding the button rather than covering it up. You will probably run into tab issues next anyway where you can tab to the covered up button.


Former Community Member

The box does appear on the first use when I click the button in any of the other instances (as you noted). I am sorry to say I am not sure how to fix it from your explanation above.

Here is the code I am using:

if (topmostSubform.Page3.InspireGroup.AddShot_subform.MenuCover.presence == "visible"){

topmostSubform.Page3.InspireGroup.AddShot_subform.MenuCover.presence = "invisible";

}else {

topmostSubform.Page3.InspireGroup.AddShot_subform.MenuCover.presence = "visible"



Level 4
I would just use the "parent/child" addressing system.

In the click event of your hide button add:

this.parent.AddressOfTheAddButtonFromTheInstance.presence = "invisible";

May need to add more "parents" (e.g. this.parent.parent.parent) depending on if you have the hide button wrapped in a few subforms.

Hope thsi helps,



What S. Bishiop is saying to use is the addressing of each instance as an individual item, e.g. :

for (var i=0; i < Question2.DeviceForm._Device.count; i++)


Question2.DeviceForm.Device.all.item(i).PositionedWrap.DeviceType.mandatory = mandatorySetting;


This loops through every instance of the repeating form "Device" and sets a field to being mandatorySetting (error or disabled, depending on what I want, in this case).


Former Community Member

Thank you so much! I used:

if (this.parent.InspireGroup.AddShot_subform.MenuCover.presence == "visible"){

this.parent.InspireGroup.AddShot_subform.MenuCover.presence = "invisible";

}else {

this.parent.InspireGroup.AddShot_subform.MenuCover.presence = "visible"


And now all my buttons in the instance behave as planned - great.