# Message handler script with perspective table component property

**URL:** <https://forum.inductiveautomation.com/t/message-handler-script-with-perspective-table-component-property/37816>\
**Category:** Ignition\
**Created:** [August 17, 2020, 5:06pm UTC](https://forum.inductiveautomation.com/t/message-handler-script-with-perspective-table-component-property/37816 "2020-08-17T17:06:26Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![mbai1](https://avatars.discourse-cdn.com/v4/letter/m/9fc29f/32.png) [@mbai1](https://forum.inductiveautomation.com/u/mbai1)\
**Post date:** [August 17, 2020, 5:06pm UTC](https://forum.inductiveautomation.com/t/message-handler-script-with-perspective-table-component-property/37816/1 "2020-08-17T17:06:26Z")

</div>

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/d/0dd0b4a446641111565e8bb76e936306a77b871f.png)  
In my message handler code, I have a script trying to access the selection data in table component in perspective. I am getting error that data is not a attribute:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/1/d19b243dfdb5378e0ba62f4244e1baff71942ffe.png)

but in the table.props. selection I can see the data:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/2/9271e36eb2b1772f0f345e073392973dc7d9a372.png)

does anyone know how i can fix this?  
thanks!

---

<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:** [August 17, 2020, 5:21pm UTC](https://forum.inductiveautomation.com/t/message-handler-script-with-perspective-table-component-property/37816/2 "2020-08-17T17:21:07Z")

</div>

I would need to see your full script to be sure, but the error message calls out line 8. Your provided code is only a few lines long and starts at line 2 in the script editor, so I can only assume you make a reference to `selectedTags` outside of the code you posted here. As `selectedTags` is a temporary variable available ONLY within the loop, your later reference is not valid.

Providing the script including line 8 would give us a better idea as to the issue.

---

<div class="post-metadata">

**Author:** ![mbai1](https://avatars.discourse-cdn.com/v4/letter/m/9fc29f/32.png) [@mbai1](https://forum.inductiveautomation.com/u/mbai1)\
**Post date:** [August 17, 2020, 5:23pm UTC](https://forum.inductiveautomation.com/t/message-handler-script-with-perspective-table-component-property/37816/3 "2020-08-17T17:23:15Z")

</div>

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/c/cc25f1e8f019d5ea8975b6e9e22b88ff8dfea7aa.png)  
sorry line 8 is the newTag line

---

<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:** [August 17, 2020, 5:31pm UTC](https://forum.inductiveautomation.com/t/message-handler-script-with-perspective-table-component-property/37816/4 "2020-08-17T17:31:03Z")

</div>

Oh, I misread the error message.

Assuming your table has a column named “path”, I think you want something like this:

```auto
for selectedTag in self.props.selection.data:
    newTags.append(selectedTag.path)

```

`self.props.selection` is an object, and so when you loop over it, you’re getting the keys of the object, and these keys are strings (unicode). This is why you’re seeing the clarification that the unicode object has no attribute “data”.

---

<div class="post-metadata">

**Author:** ![mbai1](https://avatars.discourse-cdn.com/v4/letter/m/9fc29f/32.png) [@mbai1](https://forum.inductiveautomation.com/u/mbai1)\
**Post date:** [August 17, 2020, 5:32pm UTC](https://forum.inductiveautomation.com/t/message-handler-script-with-perspective-table-component-property/37816/5 "2020-08-17T17:32:51Z")

</div>

that works, thank you for your help!

---

<div class="post-metadata">

**Author:** ![mbai1](https://avatars.discourse-cdn.com/v4/letter/m/9fc29f/32.png) [@mbai1](https://forum.inductiveautomation.com/u/mbai1)\
**Post date:** [August 17, 2020, 7:52pm UTC](https://forum.inductiveautomation.com/t/message-handler-script-with-perspective-table-component-property/37816/6 "2020-08-17T19:52:21Z")

</div>

hello, regarding to the script, I have an event script on table component to delete a plot in time series chart. I also have a message handler on timer series chart. My goal is to delete certain plot by toggle certain column in table. I try to use axis in the plot property to decide which plot i delete. I can’t quite get it to work. Could you please see what is problem might be? thanks sorry I am quite new for ignition.

my event script on table component:

```auto
	if event.column =='delete':

	   system.perspective.sendMessage('removeplot',{'axis':plot['axis']})

```

my message handler script on time series chart:

```auto
	toggleTag = payload['axis']
	togglePen = None
	plots = [plot for plot in self.props.plots]
	for plot in plots:
	    if plot.trends['axis'] == toggleTag:
	        togglePen = plot 
	    plots.remove(togglePen)

```

---

<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:** [August 17, 2020, 11:38pm UTC](https://forum.inductiveautomation.com/t/message-handler-script-with-perspective-table-component-property/37816/7 "2020-08-17T23:38:34Z")

</div>

There’s a lot of moving pieces here, so I need some more information:

1. What Event is actually invoking the script action you supplied?
2. If you print out the column, what do you see? I’m betting it’s not a simple string (unicode) - it’s probably an object, so it’ll never equal “delete”. (see example “A”)
3. Your message handler is modifying a local `plots` variable, but you aren’t doing anything with the new data. In your message handler, `plots` is a COPY of the data in `self.props.plots`. You then modify the copy and remove an entry from the list. But you haven’t changed the original data. (See example “B”)

Example A:

```auto
system.perspective.print(event.column)
if event.column == 'delete':
    system.perspective.sendMessage('removeplot',{'axis':plot['axis']})

```

Example B:

```auto
toggleTag = payload['axis']
togglePen = None
plots = self.props.plots
for plot in plots:
    # This next line will also fail, because trends is a list. you probably
    # want plot.trends[0].axis, but I'm not a Time Series Chart expert
    if plot.trends['axis'] == toggleTag:
        togglePen = plot 
    plots.remove(togglePen)
self.props.plots = plots # This is the important line

```

---

<div class="post-metadata">

**Author:** ![mbai1](https://avatars.discourse-cdn.com/v4/letter/m/9fc29f/32.png) [@mbai1](https://forum.inductiveautomation.com/u/mbai1)\
**Post date:** [August 18, 2020, 3:41pm UTC](https://forum.inductiveautomation.com/t/message-handler-script-with-perspective-table-component-property/37816/8 "2020-08-18T15:41:29Z")

</div>

hello, I got that work, so basically i use the axis to match the a parameter in a column selection, and use that to trigger the trends to be deleted. My problems was the script parts, but after I modify the example B you provide it, it works, thank you!
