Dynamic Flex Repeater with Instance Scripting: How do I set the Instance param values?

Hi all,
Been doing some reading on "Dynamic Flex Repeaters" and found a lot of good info on using a script transform on the props.instances.

Using this example by @YF129701, creating instances and setting fixed parameters are easy.

However, I would like to pass values that change depending on how many instances are needed, and values that would be associated with additional Flex Repeaters nested within them.

For my use case, there are three views: the parent, the repeaters within the parent, and the repeaters within the repeater.

Ideally, the primary and secondary repeaters would be using a script transform to set the number of instances needed, and passing other values as well.
Using this transform on a static value for testing:

	obj = {
		"instanceStyle":{"classes":""},
		"instancePosition": {}
	}
	objList = []
	for i in xrange(value):
		objList.append(obj)
	for o in objList:
		o["blockId"] = self.view.params.blockId
		o["zone"] = 1
	return objList

Returns this:


Well, each of those instances needs a different zone value. The values are not necessarily sequential either, which seems to make it more difficult. I could use a two column dataset of which zones to use, and this begs the question how would each scripted instance know which zone number to retrieve?
image

If this can be solved, I think I could use the same method to pass values to the secondary repeater to change the values you see with the light blue highlight. Currently, the secondary does not use a script transform, as I haven't figured out passing dynamic values through yet. Here are the current instances on the secondary:


bay and position determine the value of the light blue components.

Also, @bmusson mentioned he uses a message handler on the props.instances, in Ignition Early Access 2019. I am not sure this would be much different, maybe?

Thoughts on getting those dynamic values to pass to the parameters in each instance? Thanks!

Edit: I am also thinking of using the params on the secondary repeater as in/out, to pass changes back to the primary repeater, so that when the user saves the data, I can run fewer scripts on the primary repeaters, rather than 3x that on the secondary.

Don’t try to pass up state from inside doubly-nested repeaters, you’re gonna have a bad time.

Instead, pass everything down from the top level and have the inner levels send messages to the top level. The top level would perform the actions and then push the changes back down into the nested views.

Alternatively you can use @pturmel’s toolkit’s PageVarMap to hold your state; that would allow you to directly interact with the state from any level of the hierarchy.