# Message Handler problem

**URL:** <https://forum.inductiveautomation.com/t/message-handler-problem/104453>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [March 31, 2025, 12:05pm UTC](https://forum.inductiveautomation.com/t/message-handler-problem/104453 "2025-03-31T12:05:01Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aiasa21](https://avatars.discourse-cdn.com/v4/letter/a/aeb1de/32.png) [@Aiasa21](https://forum.inductiveautomation.com/u/Aiasa21)\
**Post date:** [March 31, 2025, 12:05pm UTC](https://forum.inductiveautomation.com/t/message-handler-problem/104453/1 "2025-03-31T12:05:02Z")

</div>

Good morning everyone,  
I’m having issues managing a **Message Handler**.

Here’s the logical sequence:

1. I click a **"Save"** button that opens a confirmation popup.
2. The **"Confirm"** button in the popup sends a Message Handler:

```python
system.perspective.sendMessage(messageType='Save_confirmed', payload={}, scope='page')
system.perspective.closePopup('')

```

1. The **Message Handler** in the "Save" button correctly handles data saving and then sends another Message Handler to update a table:

```python
system.perspective.sendMessage(messageType='update_table', payload={}, scope='session')

```

1. The table listens for the **Message Handler** and executes:

```python
self.refreshBinding("props.data")

```

However, the table **does not refresh**.

To troubleshoot, I added a button below the table that directly sends the **Message Handler** to the table:

```python
system.perspective.sendMessage(messageType='update_table', payload={}, scope='session')

```

Clicking this button **works correctly** , and the table updates immediately.

Where is the mistake?

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [March 31, 2025, 1:06pm UTC](https://forum.inductiveautomation.com/t/message-handler-problem/104453/2 "2025-03-31T13:06:55Z")

</div>

I would add some logging in your scripts with `system.util.getLogger()` to see if you really are sending the refresh handler message.

---

<div class="post-metadata">

**Author:** ![bschroeder](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bschroeder/32/13260_2.png) [@bschroeder](https://forum.inductiveautomation.com/u/bschroeder)\
**Post date:** [March 31, 2025, 1:09pm UTC](https://forum.inductiveautomation.com/t/message-handler-problem/104453/3 "2025-03-31T13:09:50Z")

</div>

Any errors in the Gateway logger?

---

<div class="post-metadata">

**Author:** ![Aiasa21](https://avatars.discourse-cdn.com/v4/letter/a/aeb1de/32.png) [@Aiasa21](https://forum.inductiveautomation.com/u/Aiasa21)\
**Post date:** [March 31, 2025, 2:05pm UTC](https://forum.inductiveautomation.com/t/message-handler-problem/104453/4 "2025-03-31T14:05:08Z")

</div>

No errors in the gateway.

@dkhayes117, where should I use the logger?

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [March 31, 2025, 2:08pm UTC](https://forum.inductiveautomation.com/t/message-handler-problem/104453/5 "2025-03-31T14:08:20Z")

</div>

before you call your refresh handler, and inside the refresh handler. Make sure it is being called.

The other thing to check, is if the query has caching enabled. If it does, then a `refreshBinding` will only retrieve the cached results. It will only truly refresh once the named query refreshes its cache according to the rate that it is set at.

---

<div class="post-metadata">

**Author:** ![Aiasa21](https://avatars.discourse-cdn.com/v4/letter/a/aeb1de/32.png) [@Aiasa21](https://forum.inductiveautomation.com/u/Aiasa21)\
**Post date:** [March 31, 2025, 2:14pm UTC](https://forum.inductiveautomation.com/t/message-handler-problem/104453/6 "2025-03-31T14:14:04Z")

</div>

Yes, it is logged in the table Message Handler

```python
system.util.getLogger("Message").info("Table updated")
self.refreshBinding("props.data")

```

I can read it in the gateway.

At this point as you suggest I think the problem is the timing. It looks like I read before the data is actually updated in the DB.

You mean the `Cache & Share` property?

These are the table data binding properties:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/0/c0d8e75d0b2f26dbccd331e10c327cb1f705c731.png)

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [March 31, 2025, 2:18pm UTC](https://forum.inductiveautomation.com/t/message-handler-problem/104453/7 "2025-03-31T14:18:15Z")

</div>

No, where you defined the named query in the project. It has a settings tab

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

---

<div class="post-metadata">

**Author:** ![Aiasa21](https://avatars.discourse-cdn.com/v4/letter/a/aeb1de/32.png) [@Aiasa21](https://forum.inductiveautomation.com/u/Aiasa21)\
**Post date:** [March 31, 2025, 2:20pm UTC](https://forum.inductiveautomation.com/t/message-handler-problem/104453/8 "2025-03-31T14:20:53Z")

</div>

I understand, actually it is disabled.

---

<div class="post-metadata">

**Author:** ![Aiasa21](https://avatars.discourse-cdn.com/v4/letter/a/aeb1de/32.png) [@Aiasa21](https://forum.inductiveautomation.com/u/Aiasa21)\
**Post date:** [March 31, 2025, 2:37pm UTC](https://forum.inductiveautomation.com/t/message-handler-problem/104453/9 "2025-03-31T14:37:45Z")

</div>

I'm trying to find another solution, for example if I refresh the binding directly in the save button Message Handler like this:

```python
self.getSibling("Table").refreshBinding("props.data")

```

it works, but in this case it doesn't work for all the sessions. Is there any way to refresh for everyone?

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [March 31, 2025, 2:43pm UTC](https://forum.inductiveautomation.com/t/message-handler-problem/104453/10 "2025-03-31T14:43:50Z")

</div>

You would have to mix `system.perspective.sendMessage()` with `system.util.sendMessage()` with a gateway message handler.

When you want to update the data in all open sessions, you will send a message to the project message handler (under gateway events in the project designer) with the `util.sendMessage` which will then execute the `perspective.sendMessage` part.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [March 31, 2025, 2:43pm UTC](https://forum.inductiveautomation.com/t/message-handler-problem/104453/11 "2025-03-31T14:43:54Z")

</div>

> [@Aiasa21](#):
>
> Is there any way to refresh for everyone?

Try [system.util.sendMessage | Ignition User Manual](https://www.docs.inductiveautomation.com/docs/8.1/appendix/scripting-functions/system-util/system-util-sendMessage). (Note the **util** instead of **perspective**.)

---

<div class="post-metadata">

**Author:** ![Aiasa21](https://avatars.discourse-cdn.com/v4/letter/a/aeb1de/32.png) [@Aiasa21](https://forum.inductiveautomation.com/u/Aiasa21)\
**Post date:** [March 31, 2025, 2:52pm UTC](https://forum.inductiveautomation.com/t/message-handler-problem/104453/12 "2025-03-31T14:52:59Z")

</div>

Thank you all for the suggestion, I'll make some test.
