# How to use event scripts for a component in another view

**URL:** <https://forum.inductiveautomation.com/t/how-to-use-event-scripts-for-a-component-in-another-view/37134>\
**Category:** Ignition\
**Created:** [July 27, 2020, 9:01pm UTC](https://forum.inductiveautomation.com/t/how-to-use-event-scripts-for-a-component-in-another-view/37134 "2020-07-27T21:01:37Z")\
**Posts on this page:** 12\
**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:** [July 27, 2020, 9:01pm UTC](https://forum.inductiveautomation.com/t/how-to-use-event-scripts-for-a-component-in-another-view/37134/1 "2020-07-27T21:01:37Z")

</div>

Hello, I have a tree component in a view in perspective. I want to use onItemClicked event script to control a component in another view. When I try to do it, I can’t browse the component properties that in other view. I am wondering how i can achieve my goal. Thanks

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [July 27, 2020, 9:27pm UTC](https://forum.inductiveautomation.com/t/how-to-use-event-scripts-for-a-component-in-another-view/37134/2 "2020-07-27T21:27:46Z")

</div>

You have to send a message that the other view would listen to. Component and property access is constrained to the view in which you are executing.

---

<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:** [July 28, 2020, 2:22am UTC](https://forum.inductiveautomation.com/t/how-to-use-event-scripts-for-a-component-in-another-view/37134/3 "2020-07-28T02:22:20Z")

</div>

hello, thanks for your reply, i am wokring with the message handler right, however, it only works fine within the same view, not over different views. (I checked the all three listen scopes). please let me know if there is may be something i did wrong. 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:** [July 28, 2020, 3:37am UTC](https://forum.inductiveautomation.com/t/how-to-use-event-scripts-for-a-component-in-another-view/37134/4 "2020-07-28T03:37:50Z")

</div>

Check the scope at which you “broadcast” the message, and check the scope of the component on which you configured the Message Handler script. It sounds like you might have the scope set at “view”, but your use case should probably use the “page” scope - though using “session” would probably not hurt you.

---

<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:** [July 28, 2020, 1:58pm UTC](https://forum.inductiveautomation.com/t/how-to-use-event-scripts-for-a-component-in-another-view/37134/5 "2020-07-28T13:58:01Z")

</div>

Hello, it still not solves my issues. if they are in the same view, they are working fine even i only have page scope checked. However, if there are in different view, with all scenarios of the scopes, it still not works.

---

<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:** [July 28, 2020, 2:14pm UTC](https://forum.inductiveautomation.com/t/how-to-use-event-scripts-for-a-component-in-another-view/37134/6 "2020-07-28T14:14:36Z")

</div>

Here are my configuration, and I have try out all different scenarios for the listen scope  
onitemclicked event on tree component:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/e/2ea83f1d74b76658c0e80b5d3bf2dcbcaa2cf237.png)  
messagehandler on xy chart:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/5/5530f2e782522522adc26188d5eb430879f58ca0.png)

---

<div class="post-metadata">

**Author:** ![zacht](https://avatars.discourse-cdn.com/v4/letter/z/ea5d25/32.png) [@zacht](https://forum.inductiveautomation.com/u/zacht)\
**Post date:** [July 28, 2020, 2:19pm UTC](https://forum.inductiveautomation.com/t/how-to-use-event-scripts-for-a-component-in-another-view/37134/7 "2020-07-28T14:19:01Z")

</div>

Payload isn’t an optional argument, at least according to the [documentation](https://docs.inductiveautomation.com/display/DOC80/system.perspective.sendMessage)

Try passing an empty dictionary for this argument.

---

<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:** [July 28, 2020, 2:32pm UTC](https://forum.inductiveautomation.com/t/how-to-use-event-scripts-for-a-component-in-another-view/37134/8 "2020-07-28T14:32:54Z")

</div>

Hello thanks for your help. I tried it out, but exactly same issue, work within the same view, but not in different views.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [July 28, 2020, 2:56pm UTC](https://forum.inductiveautomation.com/t/how-to-use-event-scripts-for-a-component-in-another-view/37134/9 "2020-07-28T14:56:02Z")

</div>

Try: `self.props.plots[0].trends[0].visible = False`

In Jython, any non-empty string converts to boolean as **True**.

---

<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:** [July 28, 2020, 3:01pm UTC](https://forum.inductiveautomation.com/t/how-to-use-event-scripts-for-a-component-in-another-view/37134/10 "2020-07-28T15:01:51Z")

</div>

Ye, that still not work for the different views, I am thinking if there is anything else I need to configure other than the message handler, listen scope and the onclick event.

---

<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:** [July 28, 2020, 3:49pm UTC](https://forum.inductiveautomation.com/t/how-to-use-event-scripts-for-a-component-in-another-view/37134/11 "2020-07-28T15:49:47Z")

</div>

I just tried this with the following setup and it worked:

**ViewA**  
Tree component  
EmbeddedView component (`path`="ViewB)

 ![Screen Shot 2020-07-28 at 8.45.57 AM](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/d/2d9110742ada96c4f00f980e37d2cbc830e34463.png)

**ViewB**  
XY Chart

 ![Screen Shot 2020-07-28 at 8.46.24 AM](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/a/da2bf1b5120326b69d57dbd799b54d2560041a5b.png)

Instead of using the message handler script you used I simply logged that the message was heard.

 ![Screen Shot 2020-07-28 at 8.46.32 AM](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/7/7768d338144d666450aff75fac9174d8620e12b1.png)

If you still believe this is not working, I recommend placing your own logging within your scripts so that you can see where code might not be executing. Alternatively, perhaps there’s a disconnect in the terminology we’re using, or there could be a faulty assumption about your setup. Is your XY Chart on the same page as the Tree component? Some more insight into the setup of the View might help us determine where this is going wrong for you.

---

<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:** [July 28, 2020, 4:25pm UTC](https://forum.inductiveautomation.com/t/how-to-use-event-scripts-for-a-component-in-another-view/37134/12 "2020-07-28T16:25:28Z")

</div>

Hello thank your for replying. It just work, I still don’t know why it was not. But thanks for all you guys help!
