# How to properly set Message Handler Scope

**URL:** <https://forum.inductiveautomation.com/t/how-to-properly-set-message-handler-scope/77733>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [August 11, 2023, 3:32am UTC](https://forum.inductiveautomation.com/t/how-to-properly-set-message-handler-scope/77733 "2023-08-11T03:32:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eugene49](https://avatars.discourse-cdn.com/v4/letter/e/c6cbf5/32.png) [@Eugene49](https://forum.inductiveautomation.com/u/Eugene49)\
**Post date:** [August 11, 2023, 3:32am UTC](https://forum.inductiveautomation.com/t/how-to-properly-set-message-handler-scope/77733/1 "2023-08-11T03:32:39Z")

</div>

Hi,

In this case, the sender is on a small view.  
On small view -\> root -\> onClicked event -\> sendMessage

This small view, is instantiated on a large view.  
On large view -\> root -\> script -\> message handler listening.

How do I properly set the 'minimal' scope, for communication to take place?

---

<div class="post-metadata">

**Author:** ![Patrick\_Chanthilack](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/patrick_chanthilack/32/42479_2.png) [@Patrick\_Chanthilack](https://forum.inductiveautomation.com/u/Patrick_Chanthilack)\
**Post date:** [September 5, 2023, 9:38pm UTC](https://forum.inductiveautomation.com/t/how-to-properly-set-message-handler-scope/77733/2 "2023-09-05T21:38:07Z")

</div>

Hey Eugene49, for the minimal scope you will need to specify the scope in the small view when you do [system.perspective.sendMessage](https://docs.inductiveautomation.com/display/DOC81/system.perspective.sendMessage).  
In the scope parameter, you can define the scope to be "view" in order for your execution to take place.  
We also have an example of [component message handlers](https://docs.inductiveautomation.com/display/DOC81/Component+Message+Handlers) listed in our User Manual as well.

---

<div class="post-metadata">

**Author:** ![Eugene49](https://avatars.discourse-cdn.com/v4/letter/e/c6cbf5/32.png) [@Eugene49](https://forum.inductiveautomation.com/u/Eugene49)\
**Post date:** [September 9, 2023, 8:26pm UTC](https://forum.inductiveautomation.com/t/how-to-properly-set-message-handler-scope/77733/3 "2023-09-09T20:26:11Z")

</div>

Thank you.

So I made a cheat sheet below, who's sending to where and who's listening from where.  
Sender and receiver can only communicate according to scope setting strictly.

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

---

<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 10, 2023, 3:15pm UTC](https://forum.inductiveautomation.com/t/how-to-properly-set-message-handler-scope/77733/5 "2023-09-10T15:15:55Z")

</div>

I like that diagram, but it there are some additional aspects it doesn't cover or illustrate well.

When a message is sent ("broadcast" for the rest of this post), you specify a singular scope. This specified scope determines how broadly the message will be broadcast, whether it be limited to only this View, this Page, or all Pages (browser tabs) in this Session.

When a handler/listener is configured to listen for broadcast messages, the listener can actually have multiple scopes.

Suppose I create a message (named `DEMO`) to be broadcast at the `view` scope on `DemoViewA`. I also create a second message with the same name to be broadcast with a `session` scope inside of `DemoViewB`. Within `DemoViewA` I create a handler/listener with a name of `DEMO` which will listen at both the `view` and `session` scopes.

I make two pages -- `PageA` and `PageB` -- where `PageA` contains `DemoViewA` somewhere within its content, and `PageB` contains `DemoViewB` somewhere within its content. I create a session which contains two tabs; one open to `PageA` and one open to `PageB`.

If I trigger some action on `PageB` which would broadcast my message, then the listener/handler within `DemoViewA` on `PageA` will "hear" the broadcast message because that other page is listening for the `DEMO` message at both the `view` and `session` scopes.

---

<div class="post-metadata">

**Author:** ![Eugene49](https://avatars.discourse-cdn.com/v4/letter/e/c6cbf5/32.png) [@Eugene49](https://forum.inductiveautomation.com/u/Eugene49)\
**Post date:** [September 10, 2023, 3:36pm UTC](https://forum.inductiveautomation.com/t/how-to-properly-set-message-handler-scope/77733/6 "2023-09-10T15:36:35Z")

</div>

You mean the feature where the listener can listen to multiple scope, right?

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/8/683e4bf525b6efbbdc20e059689b58f241a012ad.png)

I didn't intend the diagram to be complete, but shows basicly how the communicate.

Nice to have multiple Listen scope.
