# Dynamic Flex Repeater Instances

**URL:** <https://forum.inductiveautomation.com/t/dynamic-flex-repeater-instances/30472>\
**Category:** Ignition\
**Tags:** scripting, perspective\
**Created:** [December 5, 2019, 4:38pm UTC](https://forum.inductiveautomation.com/t/dynamic-flex-repeater-instances/30472 "2019-12-05T16:38:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![erfritts](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/erfritts/32/3660_2.png) [@erfritts](https://forum.inductiveautomation.com/u/erfritts)\
**Post date:** [December 5, 2019, 4:38pm UTC](https://forum.inductiveautomation.com/t/dynamic-flex-repeater-instances/30472/1 "2019-12-05T16:38:13Z")

</div>

I am trying to get use to this Perspective module and some of the things are giving me some headaches. I have a view setup with three labels that is supposed to be my template. I have a Flex Repeater that is set to use said view as it’s path. I can manually set 1 or 2 or more instances of my template view, but this is not what I want. I am trying to use a tag with a script transform to tell props.instances how many template views and what values to produce. The problem is I get the error:  
array found, object expected!  
The proper number of template views show so I am half way there. here is what I have:

the tag is a data set with the values for the templates labels and is being transformed with this script

```
x = []
for row in range(value.getRowCount()):
	y = []
	cols = ["partnum", "qtyscheduled", "note"]
	for cols in range(value.getColumnCount()-1):
		y.append(value.getValueAt(row, cols))
	x.append(y)
self.props.instances = x
return self.props.instances
```

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [December 5, 2019, 5:21pm UTC](https://forum.inductiveautomation.com/t/dynamic-flex-repeater-instances/30472/2 "2019-12-05T17:21:31Z")

</div>

As the error states, the params for each instance are expected to be an object. try:

```auto
x = []
for row in range(value.getRowCount()):
	y = {}
	cols = ["partnum", "qtyscheduled", "note"]
	for i in range(value.getColumnCount()-1):
		y[cols[i]] = value.getValueAt(row, i)
	x.append(y)
self.props.instances = x
return self.props.instances

```

Note: I didn’t run this myself, but this will turn your inner list into a dictionary (object), which is the structure expected for each instance’s params.

---

<div class="post-metadata">

**Author:** ![erfritts](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/erfritts/32/3660_2.png) [@erfritts](https://forum.inductiveautomation.com/u/erfritts)\
**Post date:** [December 5, 2019, 7:38pm UTC](https://forum.inductiveautomation.com/t/dynamic-flex-repeater-instances/30472/3 "2019-12-05T19:38:31Z")

</div>

That would be it. Some of my vision pieces are not translating as easy as I thought and I guess I was staring at the screen for too long. Thank you soo much. I’m glad it’s only the mobile stuff and then fresh Perspective from now on. Ha ha.

---

<div class="post-metadata">

**Author:** ![erfritts](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/erfritts/32/3660_2.png) [@erfritts](https://forum.inductiveautomation.com/u/erfritts)\
**Post date:** [December 5, 2019, 7:57pm UTC](https://forum.inductiveautomation.com/t/dynamic-flex-repeater-instances/30472/4 "2019-12-05T19:57:15Z")

</div>

I had to make one more change. the reason why I was iterating over the columns was because I was leaving out a column of the dataset I did not need. Doesn’t matter won’t have any effect in the negative to let it be there that I can tell it just won’t be printed.

```
x = []	
for row in range(value.getRowCount()):
	y = {}
	cols = ["partnum", "qtybox", "qtyscheduled", "note"]
	for i in range(value.getColumnCount()):
		y[cols[i]] = value.getValueAt(row, i)
	x.append(y)
self.props.instances = x
return self.props.instances
```
