# Attempting to remove element from Flex Repeater

**URL:** <https://forum.inductiveautomation.com/t/attempting-to-remove-element-from-flex-repeater/38867>\
**Category:** Ignition\
**Tags:** ignition80, perspective\
**Created:** [September 20, 2020, 7:58am UTC](https://forum.inductiveautomation.com/t/attempting-to-remove-element-from-flex-repeater/38867 "2020-09-20T07:58:03Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![mitchell-ACS](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mitchell-acs/32/30062_2.png) [@mitchell-ACS](https://forum.inductiveautomation.com/u/mitchell-ACS)\
**Post date:** [September 20, 2020, 7:58am UTC](https://forum.inductiveautomation.com/t/attempting-to-remove-element-from-flex-repeater/38867/1 "2020-09-20T07:58:03Z")

</div>

I am trying to set up a button on an embedded view that I have in a template repeater, that will then do an array.remove() on the instances property of the flex repeater.  
the error I am getting look like it can’t match up the element params, with the params in the view.

Event Script on the button in the embedded view

```auto
system.perspective.sendMessage('removeListItem', {'listItem':self.view.params})

```

Message handler script on the flex repeater

```auto
from com.inductiveautomation.ignition.common import TypeUtilities
listItem = TypeUtilities.pyToGson(payload['listItem'])
instances = TypeUtilities.pyToGson(self.props.instances)
instances.remove(listItem)

```

The error I am getting

```auto
com.inductiveautomation.ignition.common.script.JythonExecException
Traceback (most recent call last):
  File "<function:onMessageReceived>", line 5, in onMessageReceived
ValueError: array.remove({"alarm":false,"analogParams":{"formatString":"#,##0.#","tagPath":"[CarefreeSCADA]Customers/Demo/reservoir/Reads/Well_Flow","name":"Well Flow","engUnits":"gpm"},"analyticsParams":{"calcDuration":24,"dataAggregation":"Average","enabled":false},"instancePosition":{},"instanceStyle":{"classes":""},"popup":true}): {"alarm":false,"analogParams":{"formatString":"#,##0.#","tagPath":"[CarefreeSCADA]Customers/Demo/reservoir/Reads/Well_Flow","name":"Well Flow","engUnits":"gpm"},"analyticsParams":{"calcDuration":24,"dataAggregation":"Average","enabled":false},"instancePosition":{},"instanceStyle":{"classes":""},"popup":true} not found in array

	caused by org.python.core.PyException
Traceback (most recent call last):
  File "<function:onMessageReceived>", line 5, in onMessageReceived
ValueError: array.remove({"alarm":false,"analogParams":{"formatString":"#,##0.#","tagPath":"[CarefreeSCADA]Customers/Demo/reservoir/Reads/Well_Flow","name":"Well Flow","engUnits":"gpm"},"analyticsParams":{"calcDuration":24,"dataAggregation":"Average","enabled":false},"instancePosition":{},"instanceStyle":{"classes":""},"popup":true}): {"alarm":false,"analogParams":{"formatString":"#,##0.#","tagPath":"[CarefreeSCADA]Customers/Demo/reservoir/Reads/Well_Flow","name":"Well Flow","engUnits":"gpm"},"analyticsParams":{"calcDuration":24,"dataAggregation":"Average","enabled":false},"instancePosition":{},"instanceStyle":{"classes":""},"popup":true} not found in array

Ignition v8.1.0-rc1 (b2020091420)
Java: Azul Systems, Inc. 11.0.7

```

---

<div class="post-metadata">

**Author:** ![kgamble](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kgamble/32/8019_2.png) [@kgamble](https://forum.inductiveautomation.com/u/kgamble)\
**Post date:** [September 20, 2020, 12:58pm UTC](https://forum.inductiveautomation.com/t/attempting-to-remove-element-from-flex-repeater/38867/2 "2020-09-20T12:58:30Z")

</div>

I would bet it’s because the `instances` array is an array of ObjectWrapper() objects, not technically an array of dictionaries.you could try to not convert your `self.view.params` to json for the message handler?

Or depending on how large your list is, you could just iterate with enumerate to compare each object to the dictionary, find the index and pop it that way. Not optimal, but possible

---

<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:** [September 20, 2020, 4:50pm UTC](https://forum.inductiveautomation.com/t/attempting-to-remove-element-from-flex-repeater/38867/3 "2020-09-20T16:50:21Z")

</div>

I’m going to side with @kgamble here: when I examine the types being compared, I see that the instances are of type `array.array`, while the converted payload is of type `com.inductiveautomation.ignition.common.script.adapters.PyJsonObjectAdapter`.

Of course, all of this is far more complex than it needs to be.

1. You’ve configured the instanced View’s params to include properties it doesn’t need (increases load on running session, because all of those values are stored in the browser for each instance).
2. You’re trying to take a direct-comparison removal to remove the EXACT match (which makes sense in some ways), when you could just as easily provide a unique identifier for each instance. Is the tagPath unique? If so, just specify to remove an instance where the tagPath matches the tagPath in the payload.

---

<div class="post-metadata">

**Author:** ![mitchell-ACS](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mitchell-acs/32/30062_2.png) [@mitchell-ACS](https://forum.inductiveautomation.com/u/mitchell-ACS)\
**Post date:** [September 20, 2020, 7:47pm UTC](https://forum.inductiveautomation.com/t/attempting-to-remove-element-from-flex-repeater/38867/4 "2020-09-20T19:47:45Z")

</div>

Yeah the tagPath should be unique,  
So the solution would be as @kgamble said and use enumerate to go through the instance list, find the index where it matches tagPath then pop or delete from there?  
Thanks all, I’ll give it a try this evening!

---

<div class="post-metadata">

**Author:** ![mitchell-ACS](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mitchell-acs/32/30062_2.png) [@mitchell-ACS](https://forum.inductiveautomation.com/u/mitchell-ACS)\
**Post date:** [September 21, 2020, 4:28pm UTC](https://forum.inductiveautomation.com/t/attempting-to-remove-element-from-flex-repeater/38867/5 "2020-09-21T16:28:17Z")

</div>

Was able to test it out last night using enumerate and got it working! I set up an id param on the embedded view that gets a generated uuid whenever its created to be 100% sure I’m removing the right one. Thanks for your assistance! @kgamble @cmallonee

---

<div class="post-metadata">

**Author:** ![vani161998](https://avatars.discourse-cdn.com/v4/letter/v/ee7513/32.png) [@vani161998](https://forum.inductiveautomation.com/u/vani161998)\
**Post date:** [March 10, 2022, 8:37am UTC](https://forum.inductiveautomation.com/t/attempting-to-remove-element-from-flex-repeater/38867/6 "2022-03-10T08:37:41Z")

</div>

can u pls give me an example of what you done . i am also trying to do similar kind of work.  
Thanks in advance

---

<div class="post-metadata">

**Author:** ![gopinath.ps](https://avatars.discourse-cdn.com/v4/letter/g/7ea924/32.png) [@gopinath.ps](https://forum.inductiveautomation.com/u/gopinath.ps)\
**Post date:** [August 3, 2022, 6:15pm UTC](https://forum.inductiveautomation.com/t/attempting-to-remove-element-from-flex-repeater/38867/7 "2022-08-03T18:15:02Z")

</div>

```
del self.getSibling("FlexRepeater").props.instances[0]

```

this seem to work for me
