# FlexRepeater bindings with tags structure UDT

**URL:** <https://forum.inductiveautomation.com/t/flexrepeater-bindings-with-tags-structure-udt/82369>\
**Category:** Ignition\
**Tags:** ignition81, perspective, scripting\
**Created:** [November 27, 2023, 9:34am UTC](https://forum.inductiveautomation.com/t/flexrepeater-bindings-with-tags-structure-udt/82369 "2023-11-27T09:34:30Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michal\_Goralczyk](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/michal_goralczyk/32/55564_2.png) [@Michal\_Goralczyk](https://forum.inductiveautomation.com/u/Michal_Goralczyk)\
**Post date:** [November 27, 2023, 9:34am UTC](https://forum.inductiveautomation.com/t/flexrepeater-bindings-with-tags-structure-udt/82369/1 "2023-11-27T09:34:31Z")

</div>

Hello, I have a question about FlexRepeater and automation with the UDT tag.

I have objects that are visualized in SCADA. I would like to report connections to devices on these objects. The objects are different from each other and I would not like to prepare a new screen for each one. I decided that I will create a UDT structure, which I will pass to the screen with FlexRepeater and it will display all the errors depending on the structure passed.

Theoretically, all I would need to do is configure a UDT for each object and name the tags and flexrepeater would display everything automatically. Below is the implementation of my idea:

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/d/ed226ac7a09d8ea6cf276b54a4228574dfef9013.png)

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/8/2805b435e3c653082babf7374c19059f1caed499.png)

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/d/0d42a15e38ec0abd77cd81aea1973b8dd40ca1d6.png)

My questions:

1. does anyone know a better way to implement this?
2. how to make it pass not the tag names but the value from .Documentation to the screen?
3. why when I pass the structure to the screen the order is "scattered"

Best regards

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [November 27, 2023, 10:27am UTC](https://forum.inductiveautomation.com/t/flexrepeater-bindings-with-tags-structure-udt/82369/2 "2023-11-27T10:27:20Z")

</div>

1. You are on the right track but without the binding details and UDT structure it's a bit hard to tell what's going on.
2. Here's one way:

- On the subview create a parameter `tagPath`.
- On the subview label's `props.text` create an expression binding  
`tag({view.params.tagPath} + '.Documentation')`

1. Jython / Python 2.7 does not preserve order in dictionaries (but does in lists) and I expect that's the problem. Show us the `instances` binding and we may find a fix in there.

[https://docs.inductiveautomation.com/display/DOC81/tag](https://docs.inductiveautomation.com/display/DOC81/tag)

---

<div class="post-metadata">

**Author:** ![Michal\_Goralczyk](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/michal_goralczyk/32/55564_2.png) [@Michal\_Goralczyk](https://forum.inductiveautomation.com/u/Michal_Goralczyk)\
**Post date:** [November 27, 2023, 10:33am UTC](https://forum.inductiveautomation.com/t/flexrepeater-bindings-with-tags-structure-udt/82369/3 "2023-11-27T10:33:52Z")

</div>

Instances binding:

```auto
def transform(self, value, quality, timestamp):
	
	outputList = []
	
	for key, value in value.items():
	    element = {
	        "instanceStyle": {
	            "classes": ""
	        },
	        "instancePosition": {},
	        "Description": key,
	        "State": value
	    }
	    outputList.append(element)
	
	
	return outputList

```

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [November 27, 2023, 10:36am UTC](https://forum.inductiveautomation.com/t/flexrepeater-bindings-with-tags-structure-udt/82369/4 "2023-11-27T10:36:35Z")

</div>

That code is fine in that it's generating a **list** but it's working from **value** which is being passed into the transform. That seems to be the dictionary causing your problem. What's generating `value`?

It's probably not a great idea writing `for key, value in value.items():`. I'd pick a variable name other than `value`. Maybe,  
`for k, v in value.items():`

---

<div class="post-metadata">

**Author:** ![Michal\_Goralczyk](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/michal_goralczyk/32/55564_2.png) [@Michal\_Goralczyk](https://forum.inductiveautomation.com/u/Michal_Goralczyk)\
**Post date:** [November 27, 2023, 11:14am UTC](https://forum.inductiveautomation.com/t/flexrepeater-bindings-with-tags-structure-udt/82369/5 "2023-11-27T11:14:42Z")

</div>

Data is taken from the structure of the UDT:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/8/28b43682c7acc2a9ada29790e411c2c2093c5206.png)

Edit:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/4/e40ee093cf3ea804cb7539a8a4b67ce919018707.png)

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [November 27, 2023, 12:31pm UTC](https://forum.inductiveautomation.com/t/flexrepeater-bindings-with-tags-structure-udt/82369/6 "2023-11-27T12:31:37Z")

</div>

OK, the problem is that Status structure is being returned as a dictionary. I'm not sure what your best option is here.

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [November 27, 2023, 1:18pm UTC](https://forum.inductiveautomation.com/t/flexrepeater-bindings-with-tags-structure-udt/82369/7 "2023-11-27T13:18:20Z")

</div>

I don't understand the point of the UDT here, you don't seem to be instantiating it more than once. Are you ?

`for key, value in value.items():`  
Don't do this. I mean, reusing `value`.  
2 reasons:

- it makes things hard to follow
- while things work as you expect in the loop, you might get surprises afterward. exemple:

```python
value = {'foo{}'.format(n): n for n in xrange(10)}
for key, value in value.iteritems():
    pass
print value
# > 5 (or some other value between 0 and 9 as dicts are unordered)

```

`value` is now the last value you got while iterating through the dictionary.

Same thing for lists:

```python
value = [n for n in xrange(10)]
for value in value:
	pass
print value
# > 9

```

---

<div class="post-metadata">

**Author:** ![Michal\_Goralczyk](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/michal_goralczyk/32/55564_2.png) [@Michal\_Goralczyk](https://forum.inductiveautomation.com/u/Michal_Goralczyk)\
**Post date:** [November 27, 2023, 1:52pm UTC](https://forum.inductiveautomation.com/t/flexrepeater-bindings-with-tags-structure-udt/82369/8 "2023-11-27T13:52:47Z")

</div>

> [@pascal.fragnoud](#):
>
> I don't understand the point of the UDT here, you don't seem to be instantiating it more than once. Are you ?

I do this because I have dozens of objects that will have such UDT and will differ slightly from each other, so I do not want to create another view. Ideally, I would configure the UDT and the data would be displayed automatically on one view.

---

<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 27, 2023, 1:56pm UTC](https://forum.inductiveautomation.com/t/flexrepeater-bindings-with-tags-structure-udt/82369/9 "2023-11-27T13:56:29Z")

</div>

> [@Michal\_Goralczyk](#):
>
> will differ slightly from each other

Then you should not be using the UDT in the UI. Or rather, you should be sure to **not** use UDT properties. Just use tag path properties in all of your views. Then your tag hierarchy can use any number of independent UDTs as needed by your hardware, and your views can accommodate them as long as you use common UDT member names.

UDTs are wonderful for creating and maintaining large, complex hierarchies of tags. They are terrible on the user interface side.

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [November 27, 2023, 2:11pm UTC](https://forum.inductiveautomation.com/t/flexrepeater-bindings-with-tags-structure-udt/82369/10 "2023-11-27T14:11:17Z")

</div>

I still don't see how UDTs can help...
