Message Handler problem

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:
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:
system.perspective.sendMessage(messageType='update_table', payload={}, scope='session')
  1. The table listens for the Message Handler and executes:
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:

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

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

Where is the mistake?

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

Any errors in the Gateway logger?

No errors in the gateway.

@dkhayes117, where should I use the logger?

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.

Yes, it is logged in the table Message Handler

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:

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

I understand, actually it is disabled.

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

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?

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.

Try system.util.sendMessage | Ignition User Manual. (Note the util instead of perspective.)

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