# Flex Repeater, iterate through based on tag structure value

**URL:** <https://forum.inductiveautomation.com/t/flex-repeater-iterate-through-based-on-tag-structure-value/98752>\
**Category:** Ignition\
**Created:** [November 18, 2024, 7:13pm UTC](https://forum.inductiveautomation.com/t/flex-repeater-iterate-through-based-on-tag-structure-value/98752 "2024-11-18T19:13:15Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brian\_Stilson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/brian_stilson/32/73410_2.png) [@Brian\_Stilson](https://forum.inductiveautomation.com/u/Brian_Stilson)\
**Post date:** [November 18, 2024, 7:13pm UTC](https://forum.inductiveautomation.com/t/flex-repeater-iterate-through-based-on-tag-structure-value/98752/1 "2024-11-18T19:13:15Z")

</div>

I'm trying to use a Flex Repeater to iterate through a tag folder, look inside each tag folder, see if a particular tag is flagged on or off, and insert a template based on that status. My tag structure is set up as PLC Tags/Pumps/ and then inside Pumps is a UDT instance for each pump, called 1 through 6, and then another called Master. Inside the Pump UDT is a "Visibility" boolean element that reads a bit in the PLC. This bit designates if the pump is actually present or not.

I have a template view set up to read the same pump tag structure. Is there a way to iterate through, and for each tag folder where the visibility boolean is on, create a template instance that matches?

Edit: this is in Ignition Edge

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [November 18, 2024, 7:23pm UTC](https://forum.inductiveautomation.com/t/flex-repeater-iterate-through-based-on-tag-structure-value/98752/2 "2024-11-18T19:23:33Z")

</div>

A flex repeater is only going to repeat a single view. You can create a vew for this purpose that includes an indirect tag binding for the boolean tag, and include an embedded view whose view path is conditional on that boolean property.

---

<div class="post-metadata">

**Author:** ![Brian\_Stilson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/brian_stilson/32/73410_2.png) [@Brian\_Stilson](https://forum.inductiveautomation.com/u/Brian_Stilson)\
**Post date:** [November 18, 2024, 7:45pm UTC](https://forum.inductiveautomation.com/t/flex-repeater-iterate-through-based-on-tag-structure-value/98752/3 "2024-11-18T19:45:43Z")

</div>

They are all the same view. What varies is how many there are, and currently the customer does this with a boolean in the PLC. Probably not ideal, but this is a retrofit and changing the PLC program is a last resort.

I was able to turn visibility on and off just by using separate embedded views on my dashboard page. I may end up just doing that. It's what their existing Panelview Plus app does now, and while I'd love to do this all "the right way," I'm afraid I might have to be picking my battles on this project due to time constraints. If only we were programming the PLC, too.

---

<div class="post-metadata">

**Author:** ![David\_Stone](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/david_stone/32/79749_2.png) [@David\_Stone](https://forum.inductiveautomation.com/u/David_Stone)\
**Post date:** [November 18, 2024, 8:46pm UTC](https://forum.inductiveautomation.com/t/flex-repeater-iterate-through-based-on-tag-structure-value/98752/4 "2024-11-18T20:46:41Z")

</div>

I would normally write a binding script on the `instances` param that scans the folder of pumps and for each pump with visibility enabled, I append another instance to a JSON array that becomes the return value that populates the `instance` parameter.

```python
def transform(self, value, quality, timestamp):
	totalPumpUdts = 10 #Total number of pumps to scan through
	
	tagPaths = []
	instances = []
	
	#Make a list of tag paths to read the pump visibility from
	for pump in range(totalPumpUdts):
		tagPaths.append("[default]PLC Tags/Pumps/Pump " + str(pump+1) + "/Visibility")
	tagResults = system.tag.readBlocking(tagPaths)
	
	#Build instance array
	for visiblePump in tagResults:
		if visiblePump.value:
			instances.append({
			    "instanceStyle": {
			    "classes": ""
			    	},
			    "instancePosition": {},
			    "udtPath": "[default]PLC Tags/Pumps/Pump " + str(visiblePump+1),
				})
	return instances

```

---

<div class="post-metadata">

**Author:** ![Brian\_Stilson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/brian_stilson/32/73410_2.png) [@Brian\_Stilson](https://forum.inductiveautomation.com/u/Brian_Stilson)\
**Post date:** [November 18, 2024, 10:17pm UTC](https://forum.inductiveautomation.com/t/flex-repeater-iterate-through-based-on-tag-structure-value/98752/5 "2024-11-18T22:17:35Z")

</div>

Thanks for the advice! I had to adapt it for some of the weirdness I have (not all the pumps are numbered), but it works beautifully.
