# Out parameters of a view not updated

**URL:** <https://forum.inductiveautomation.com/t/out-parameters-of-a-view-not-updated/70579>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [March 3, 2023, 8:49am UTC](https://forum.inductiveautomation.com/t/out-parameters-of-a-view-not-updated/70579 "2023-03-03T08:49:51Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![AGOSTINO\_SCLAUZERO](https://avatars.discourse-cdn.com/v4/letter/a/eada6e/32.png) [@AGOSTINO\_SCLAUZERO](https://forum.inductiveautomation.com/u/AGOSTINO_SCLAUZERO)\
**Post date:** [March 3, 2023, 8:49am UTC](https://forum.inductiveautomation.com/t/out-parameters-of-a-view-not-updated/70579/1 "2023-03-03T08:49:51Z")

</div>

I created a perspective view with nothing but a TextField.  
The view has a param called "MyOutParm" that is set as an output param \*\*and is bound to the TextField's text property.

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

I called the view I've just created Subview, and i created a second view, the MainView that is going to use this subview.  
I want to show what seems to be a bug in the way MyOutParam is returned when the subview instances are added dynamically.

So in my MainView I added a FlexRepeater with path set to SubView.  
Additionally i added an instance of subview via designer. This is for test completeness and infact it works fine.  
Then I added a button for adding an instances to FlexRepeater's instance property, a button for setting instances property (so replacing all the instances at once), and here is where the problems arise.

Then, for showing the problem I put a button and a TextArea; when this button is pressed, the content of FlexRepeater's Instances property is display on the TextArea.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/7/976897d8969c1ac50ca0d908609a30c05399aa36.png)

The code of Add Instance:

```
newInstance = {}	
self.getSibling("FlexRepeater").props.instances.append(newInstance)

```

The code of Replace Instances:

```
newInstance = {}	
newInstances = []	
newInstances.append(newInstance)
self.getSibling("FlexRepeater").props.instances = newInstances

```

The code of DisplayFlexrepeaterInsances:

```
insts = self.getSibling(FlexRepeater).props.instances
self.getSibling(TextArea).props.text = insts

```

Pressing Add Instance and then the display button, what I get is:

```
[{"MyOutParam":"initial text","instancePosition":{},"instanceStyle":{"classes":""}},
{"MyOutParam":"initial text"}]

```

You see that the second item gets correcly created and even if I didn't add MyOutParam when I created it, the param is correcly added by the component.  
Adding instnaces always work.  
Now, if i click on 'Replace instances', that sets the whole Instances property, and then I click on the display button, what I get is:  
[{}]  
That is, MyOutParam is not created by the subview.

I bumped into this because I populate instances from database records by binding the instance property of FlexRepeater to a property that conatins a resultset.

```
res = []
for i in range(0, value.getRowCount()):
	viewParams = {}
	viewParams["id"] = value.getValueAt(i, "ID")
	res.append(viewParams)			
return res

```

Now I'm considering just clearing the array and adding the new instances, but how to do this when the instance property is set via binding? Seems not possibile, and it may require an other approach, maybe a change script on the origin property.

---

<div class="post-metadata">

**Author:** ![kyler.kamyszek](https://avatars.discourse-cdn.com/v4/letter/k/a4c791/32.png) [@kyler.kamyszek](https://forum.inductiveautomation.com/u/kyler.kamyszek)\
**Post date:** [March 3, 2023, 4:44pm UTC](https://forum.inductiveautomation.com/t/out-parameters-of-a-view-not-updated/70579/2 "2023-03-03T16:44:06Z")

</div>

Use messages to get the data out of the subviews. Have a listener on the parent page then you can handle the data outside of the repeater. Just send any identifying data in the payload. You can use an input parameter in the subviews to hold that identifying data.

Put the system.perspective.sendMessage() method on the subview components and add a Script on the parent page listening for those messages.

---

<div class="post-metadata">

**Author:** ![peter.dolberg](https://avatars.discourse-cdn.com/v4/letter/p/d9b06d/32.png) [@peter.dolberg](https://forum.inductiveautomation.com/u/peter.dolberg)\
**Post date:** [March 13, 2023, 10:49pm UTC](https://forum.inductiveautomation.com/t/out-parameters-of-a-view-not-updated/70579/3 "2023-03-13T22:49:49Z")

</div>

I have also encountered this problem with out parameter and FlexRepeaters. This is clearly a bug in the implementation of the FlexRepeater and Inductive Automation should fix it. It still exists on the latest stable version of Ignition as of this writing: 8.1.25.

**Workaround**

The approach @kyler.kamyszek proposed should work, but it's annoying to have to create message handlers for getting data that should be directly accessible via out parameters. Until this bug is fixed, using message handlers is probably the best workaround.

**To reproduce the bug**

To illustrate the bug and provide a reproducible example, I've created a view that has a FlexRepeater and another view (subview) that the FlexRepeater uses.

Here's the export: [flexrepeater-outparam-bug.zip](https://forum.inductiveautomation.com/uploads/short-url/ixtpvIZ6WZVW6fMMLjS9Y7oJxXJ.zip) (9.5 KB)

The top text area takes comma delimited string and splits the string when the button is pressed. The string is split and each piece is used as an `in` parameter for an object in the FlexRepeater's instances array . The `out` parameter in the subview is bound to the `in` parameter value.

This first screenshot is when you first load the view and press the "Split on commas" button. You can see that each subview has an `in` and an `out` parameter, and that the FlexRepeater `instances` each have an `in` and and `out` also.

 ![flexrepeater_outparam_bug1](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/8/6870c64504d7a2573b2ea70c383ac0abbf0dc9ab.png)

If you add `,c` to the string and click "Split on commas" again, you can see that the subview parameters are as expected, but the `out` parameter is missing from the original two objects in the FlexRepeater instances array. Each of the objects in the instances array should have both an `in` and an `out`. Clearly the `out` binding on the subview was evaluated since it's shown in the Subview Parameters section. It's just that `out` is no longer present/accessible in in the FlexRepeater instances property.

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

---

<div class="post-metadata">

**Author:** ![avaughn](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/avaughn/32/38972_2.png) [@avaughn](https://forum.inductiveautomation.com/u/avaughn)\
**Post date:** [April 7, 2023, 4:54pm UTC](https://forum.inductiveautomation.com/t/out-parameters-of-a-view-not-updated/70579/4 "2023-04-07T16:54:58Z")

</div>

After digging into this a bit, it was determined that it’s not a bug. What’s happening in both the original post’s ReplaceInstances method and the replication with the “Split on commas” actionPerformed script, is that the instances property is being set to an array that no longer contains the output parameters. The output parameters will not propagate back out from the subview to the Flex Repeater until the value of the output parameter(s) change.

---

<div class="post-metadata">

**Author:** ![peter.dolberg](https://avatars.discourse-cdn.com/v4/letter/p/d9b06d/32.png) [@peter.dolberg](https://forum.inductiveautomation.com/u/peter.dolberg)\
**Post date:** [April 17, 2023, 5:03pm UTC](https://forum.inductiveautomation.com/t/out-parameters-of-a-view-not-updated/70579/5 "2023-04-17T17:03:41Z")

</div>

Further workarounds I've found:

**Synchronize properties to existing instances**

Instead of replacing existing instances in the FlexRepeater, copy properties over to the existing instances. It's quite annoying to have to do this, but if you do it then the out parameters won't disappear. The basic approach was to step through the new array and the existing instances one by one and copying properties from the new one to the existing instances array. If the new array was longer then I'd append instances to the existing instances array. If the new array was shorter, then I'd remove instances from the existing instances array.

This is probably the workaround I'll use in the future.

**Remove all instances, then replace the instances**

Another workaround is to completely remove all the instances (e.g. assign `flexrepeater.props.instances=[]`) and then assign the new array values to instances. This workaround was mentioned in [another issue](https://forum.inductiveautomation.com/t/flex-repeater-output-param-in-view-not-matching-instances-array/49193/4).The downside to this approach is that any state held in input components, like text fields, will get wiped out. Also, there may be a brief moment where the view shows all the instances missing.

**Force the output to change**

When instances are replaced, the out parameters won't be propagated to the new instances unless the value _changes_. I found that even if I change the input properties, and the output parameter binding is re-evaluated, then the out parameter still won't be present on the flex repeater instance unless the output parameter changes. One such way to force a change is to have a constantly changing value, like a timestamp, be part of the output parameter. In such a case, a single output property could be an object like `{"out":"real_out_value", "dummy":1681427822105}`.

The `out` part of the object may never change, but the `dummy` value does, thus forcing the whole out parameter to change. I only add this workaround for completeness since it would be a very ugly and annoying way of ensuring out parameters are populated.
