# Send messagebox to all clients

**URL:** <https://forum.inductiveautomation.com/t/send-messagebox-to-all-clients/26322>\
**Category:** Ignition\
**Tags:** vision\
**Created:** [July 5, 2019, 10:26pm UTC](https://forum.inductiveautomation.com/t/send-messagebox-to-all-clients/26322 "2019-07-05T22:26:51Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![wakaguaka](https://avatars.discourse-cdn.com/v4/letter/w/ea666f/32.png) [@wakaguaka](https://forum.inductiveautomation.com/u/wakaguaka)\
**Post date:** [July 5, 2019, 10:26pm UTC](https://forum.inductiveautomation.com/t/send-messagebox-to-all-clients/26322/1 "2019-07-05T22:26:51Z")

</div>

Hello community,  
I am working on a routine that is fired through a tag change in the gateway scripts.  
1.- Saves information to a database  
2.- If save process fails, it saves values to memory tags and another gateway time script is in charge to retry saving data to database  
3.- If retry fails in 'N' attempts, an error is registered in Ignition's log (getLogger) and an alarm is being fired as well.

Now, the customer wants a popup (a messagebox) to all the clients connected if that error ocurres.  
Since this is running in gateway scope, I cannot use system.gui.messageBox am I right?

Tried using the sendMessage but maybe this doesn't work for what the customer needs?  
Example

```python
system.util.sendMessage(project='X', messageHandler='SCIAHandler',payload={'msg':"Hello world"}, scope='C')

```

Cheers,

---

<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 5, 2019, 11:36pm UTC](https://forum.inductiveautomation.com/t/send-messagebox-to-all-clients/26322/2 "2019-07-05T23:36:56Z")

</div>

sendMessage is exactly what you want. The messageHandler in client scope can use system.gui.messageBox().

---

<div class="post-metadata">

**Author:** ![wakaguaka](https://avatars.discourse-cdn.com/v4/letter/w/ea666f/32.png) [@wakaguaka](https://forum.inductiveautomation.com/u/wakaguaka)\
**Post date:** [July 8, 2019, 1:56pm UTC](https://forum.inductiveautomation.com/t/send-messagebox-to-all-clients/26322/3 "2019-07-08T13:56:10Z")

</div>

Thank you for pointing me in the right direction pturmel. Is it possible to send one message to all projects in ignition?  
Or do I need to send multiple messages to all projects?

```auto
system.util.sendMessage(messageHandler='SCIAHandler',payload={'msg':"Hello world"}, scope='C')

```

or mandatory:

```auto
system.util.sendMessage(project='X', messageHandler='SCIAHandler',payload={'msg':"Hello world"}, scope='C')
system.util.sendMessage(project='Y', messageHandler='SCIAHandler',payload={'msg':"Hello world"}, scope='C')
system.util.sendMessage(project='Z', messageHandler='SCIAHandler',payload={'msg':"Hello world"}, scope='C')

```

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [July 8, 2019, 2:27pm UTC](https://forum.inductiveautomation.com/t/send-messagebox-to-all-clients/26322/4 "2019-07-08T14:27:21Z")

</div>

Project appears to be a required parameter. But, you can make a loop to handle the separate projects:

```python
### Example 1: send to all running sessions

# Get information for all running sessions
sessions = system.util.getSessionInfo()

# Extract project names
projectSet = set([s['project'] for s in sessions if not s['isDesigner']])

# Send messages
for p in projectSet:
  system.util.sendMessage(project=p, messageHandler='SCIAHandler',payload={'msg':"Hello world"}, scope='C')
  
############################################################################################

### Example 2: Send to specific projects

# Make a list of projects
projectList = ['X', 'Y', 'Z']
# Send messages
for p in projectList:
  system.util.sendMessage(project=p, messageHandler='SCIAHandler',payload={'msg':"Hello world"}, scope='C')

```

---

<div class="post-metadata">

**Author:** ![jorgegonzalez](https://avatars.discourse-cdn.com/v4/letter/j/a5b964/32.png) [@jorgegonzalez](https://forum.inductiveautomation.com/u/jorgegonzalez)\
**Post date:** [June 7, 2020, 8:32pm UTC](https://forum.inductiveautomation.com/t/send-messagebox-to-all-clients/26322/5 "2020-06-07T20:32:22Z")

</div>

> [@wakaguaka](#):
>
> in gateway scope

Hi Pturmel, I am trying to do something quite similar using sendMessage as well but honestly, this is new for me, do you have any example about it? everything than I have to do for a successful process.  
Regards  
Jorge

---

<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:** [June 7, 2020, 9:23pm UTC](https://forum.inductiveautomation.com/t/send-messagebox-to-all-clients/26322/6 "2020-06-07T21:23:14Z")

</div>

The only thing missing from Jordan’s example is the one-line code in a [client message handler](https://docs.inductiveautomation.com/display/DOC80/Client+Event+Scripts#ClientEventScripts-MessageScripts) that calls [system.gui.messageBox](https://docs.inductiveautomation.com/display/DOC79/system.gui.messageBox). Something like this:

```python
	system.gui.messageBox(payload['msg'], "Global Alert!")

```

Consider going through the free, online [Inductive University](https://www.inductiveuniversity.com/courses/ignition-overview/8.0) training.

---

<div class="post-metadata">

**Author:** ![yifeiliu08](https://avatars.discourse-cdn.com/v4/letter/y/bbe5ce/32.png) [@yifeiliu08](https://forum.inductiveautomation.com/u/yifeiliu08)\
**Post date:** [February 7, 2022, 7:01am UTC](https://forum.inductiveautomation.com/t/send-messagebox-to-all-clients/26322/7 "2022-02-07T07:01:39Z")

</div>

Hi Jordan  
I have try the code, it works in vision.  
Just one more question, if I want to these message popup out in perspective module that running on a mobile end point(ZEBRA TC21), and also make the device vibrate, can this realize?

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [February 7, 2022, 1:59pm UTC](https://forum.inductiveautomation.com/t/send-messagebox-to-all-clients/26322/8 "2022-02-07T13:59:38Z")

</div>

Untried, I’d say the scope of the message would need to include an ‘S’, with a session message event having a script to containing your vibrate and popup commands.
