# Update a table with .refreshBinding or Query Polling but not Both

**URL:** <https://forum.inductiveautomation.com/t/update-a-table-with-refreshbinding-or-query-polling-but-not-both/78488>\
**Category:** Ignition\
**Tags:** ignition81, perspective, scripting\
**Created:** [August 29, 2023, 1:25am UTC](https://forum.inductiveautomation.com/t/update-a-table-with-refreshbinding-or-query-polling-but-not-both/78488 "2023-08-29T01:25:39Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![r123](https://avatars.discourse-cdn.com/v4/letter/r/838e76/32.png) [@r123](https://forum.inductiveautomation.com/u/r123)\
**Post date:** [August 29, 2023, 1:25am UTC](https://forum.inductiveautomation.com/t/update-a-table-with-refreshbinding-or-query-polling-but-not-both/78488/1 "2023-08-29T01:25:39Z")

</div>

It's looks like I can not update the Perspective table with .refreshBinding if I'm also using polling.  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/3/a3fa5ccfec0c36bc46deb503ef1cdf3538c4379c.png)

I just wanted to do the manual update in a button that removed items from the table so the operator would see it immediately.  
`self.parent.parent.getChild("Table_BAD_POSTs").refreshBinding("props.data")`

If I remove the polling setting where is the best place to put the `refreshBinding` script so it will also run on it's own? I'm guessing I can't have a Gateway Timer update the Perspective table?

---

<div class="post-metadata">

**Author:** ![bmeyers](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bmeyers/32/37453_2.png) [@bmeyers](https://forum.inductiveautomation.com/u/bmeyers)\
**Post date:** [August 29, 2023, 11:59am UTC](https://forum.inductiveautomation.com/t/update-a-table-with-refreshbinding-or-query-polling-but-not-both/78488/2 "2023-08-29T11:59:26Z")

</div>

You could use a message handler to receive a message that refreshes a particular binding.

[https://docs.inductiveautomation.com/display/DOC80/Component+Message+Handlers](https://docs.inductiveautomation.com/display/DOC80/Component+Message+Handlers)

I set the scope to page typically and then send a message to refresh a binding when the user clicks a particular button.

---

<div class="post-metadata">

**Author:** ![r123](https://avatars.discourse-cdn.com/v4/letter/r/838e76/32.png) [@r123](https://forum.inductiveautomation.com/u/r123)\
**Post date:** [August 29, 2023, 10:55pm UTC](https://forum.inductiveautomation.com/t/update-a-table-with-refreshbinding-or-query-polling-but-not-both/78488/3 "2023-08-29T22:55:55Z")

</div>

Seems to work but took me hours as always and not sure its correct. 🙂

Is there a good way to get around hard coding the application name?

Added Gateway Timer.  
`system.util.sendMessage("DFW02", "refresh", scope="S")`

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

Then a Session Event.  
`system.perspective.sendMessage('refresh', {}, scope="session")`

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

And a Message Handler on the Table. Seems to need the Session Scope checked.  
`self.refreshBinding('props.data')`  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/3/8353982b521cf6dd60fc78f04b44bdc47c6bdf7b.png)

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [August 29, 2023, 11:04pm UTC](https://forum.inductiveautomation.com/t/update-a-table-with-refreshbinding-or-query-polling-but-not-both/78488/4 "2023-08-29T23:04:44Z")

</div>

> [@r123](#):
>
> It's looks like I can not update the Perspective table with .refreshBinding if I'm also using polling.

Let's go back to first principles.

I'm pretty sure this statement is not correct. What lead you to that conclusion?

The next person coming after you maintain this is, 100% of the time, _not_ going to go looking in gateway timer scripts for an event that refreshes a query binding in a Perspective session.  
I'm pretty confident you can still have the binding poll, _and_ trigger a refresh with a "local" broadcast from a button, as @bmeyers was suggesting.

---

<div class="post-metadata">

**Author:** ![r123](https://avatars.discourse-cdn.com/v4/letter/r/838e76/32.png) [@r123](https://forum.inductiveautomation.com/u/r123)\
**Post date:** [August 29, 2023, 11:18pm UTC](https://forum.inductiveautomation.com/t/update-a-table-with-refreshbinding-or-query-polling-but-not-both/78488/5 "2023-08-29T23:18:17Z")

</div>

> [@paul-griffith](#):
>
> I'm pretty sure this statement is not correct. What lead you to that conclusion?

I may have had something set incorrectly but I was able to toggle the issue by disabling or enabling polling.

Polling on, Table would update every minute but the button with .refreshBinding would not update the table.

Polling off, the Table would now update with the button but then not automatically.

---

<div class="post-metadata">

**Author:** ![bmeyers](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bmeyers/32/37453_2.png) [@bmeyers](https://forum.inductiveautomation.com/u/bmeyers)\
**Post date:** [August 30, 2023, 1:25pm UTC](https://forum.inductiveautomation.com/t/update-a-table-with-refreshbinding-or-query-polling-but-not-both/78488/6 "2023-08-30T13:25:52Z")

</div>

Good work figuring out message handlers they are very powerful.

I was looking through my project(s) and I actually don't have polling turned on anywhere recently. Polling usually got me in trouble since I could bog down the network accidentally. I turned it on, saved the project, and was able to trigger the refresh through a button.

Here is my code example:

```auto
# Code called by button on same *page*.
messageType = 'refresh-data-binding'
payload = {}
system.perspective.sendMessage(messageType, payload, scope='page')
```

```auto
# Code called on Message Handler
self.refreshBinding(props.data)
self.props.selection.selectedRow = None
self.props.selection.selectedColumn = None
```

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

One thing I would mention is make your message handler scope as small as it needs to be. If you don't need to refresh something then don't.

---

<div class="post-metadata">

**Author:** ![r123](https://avatars.discourse-cdn.com/v4/letter/r/838e76/32.png) [@r123](https://forum.inductiveautomation.com/u/r123)\
**Post date:** [August 30, 2023, 4:36pm UTC](https://forum.inductiveautomation.com/t/update-a-table-with-refreshbinding-or-query-polling-but-not-both/78488/7 "2023-08-30T16:36:18Z")

</div>

I put everything back last night and it worked. ??? I have no clue why it was not working before. I tried it many times before posting. So when I saw your suggestion I was thinking I had to use a message handler to make it work.

So the correct answer is that you can do both without using a message handler and local broadcast on the button. I could last night anyway.

I just keep running into random things that don't work for some reason. I just spent some time yesterday with the default table column sort. It was working then I just had one table ignore the setting. Then I found a post saying it's a known bug if you have a binding on the table. I was going to give up on it but later found in another thread that you can make it work with the Persistent setting.

Thanks for the info and it's good to know more about message handlers, I'm sure I'll need them at some point.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [August 30, 2023, 4:39pm UTC](https://forum.inductiveautomation.com/t/update-a-table-with-refreshbinding-or-query-polling-but-not-both/78488/8 "2023-08-30T16:39:21Z")

</div>

The `perspective.binding.AbstractPolling` logger at trace level should have some good information about what's going on with the binding's internal evaluation state, though it'll be noisy if you try to test on a production system.
