Hello, I read in other threads that this is not possible, but I wanted to get some more information on other possible ways.
I have a FlexRepeater with the “instances” array bound to a script that generates a list of arrays with this structure: 0: UDT: data: value MHE: value1
The script basically gets the tag provider and selects some tags in a for loop to generate the instances of a template by returning a list with this structure
I need to bind the UDT array in my instances to different tags that the script selects. Can I pass through this script the binding information? Or can you point me in the right direction?
Wrong approach, configure your embedded view to accept a tag path string. Pass the UDT tag path to the embedded view. On your embedded view, use the base UDT tag path to drive indirect bindings for each of the necessary UDT members. Each member should have its own private custom property at the view level. Bind display/control elements to these custom properties as necessary.
While this is for a popup, the exact same method can be used for views in a repeater:
While this link is for vision, the same logic can be applied to perspective:
You'll get an array of values, with that array you can create a flex repeater with the format you need.
Be careful with the system.tag.readBlocking function, this function creates a thread in the gateway, don't use it with constant generated data, this is perfect to get the configuration, if you need to have a constant reading it's better to use system.tag.readAsync.
This is incorrect and inefficient, if you need anything other than a value snapshot, you should be utilizing (indirect) tag bindings. If the values are being displayed via embedded views, the bindings should be configured in the embedded view and generated from the tag path(s) passed to the embedded view as parameters.
Fair point, Ryan. Indirect tag bindings are definitely more efficient for standard UI displays. However, since we don't know exactly how many tags need to be read, configuring individual bindings would be inefficient. As he mentioned needing these for a Flex Repeater, another alternative would be to pass the tagPath to the repeater and let the child view handle the indirect tagging. That said, I find that scripting often provides better maintainability when dealing with dynamic arrays that reads more that just one value of the UDT. But you're right, for a single value snapshot, bindings are the way to go.
It appears I was unclear, I was advising to create the indirect tag bindings on the embedded view as you mentioned. I've edited my comment to prevent confusion.