# Query binding not refreshing with the refreshBinding command

**URL:** <https://forum.inductiveautomation.com/t/query-binding-not-refreshing-with-the-refreshbinding-command/73917>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [May 18, 2023, 6:12pm UTC](https://forum.inductiveautomation.com/t/query-binding-not-refreshing-with-the-refreshbinding-command/73917 "2023-05-18T18:12:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Charles\_Belanger](https://avatars.discourse-cdn.com/v4/letter/c/5fc32e/32.png) [@Charles\_Belanger](https://forum.inductiveautomation.com/u/Charles_Belanger)\
**Post date:** [May 18, 2023, 6:12pm UTC](https://forum.inductiveautomation.com/t/query-binding-not-refreshing-with-the-refreshbinding-command/73917/1 "2023-05-18T18:12:21Z")

</div>

Hi,  
I have text boxes that update based on a query. The user can add a comment in a text input box, which then gets put into a database and read back by a named query.

The problem is that the query binding doesn't update when it should. I have programmed a button to add the comment in the database and update the query to show the entered text on screen.

Right now, I send a message from the button after uploading to the DB, which should get read by a messageHandler on the comment table component. The message handler only contains `self.refreshBinding("custom.downtimeCommentData")`. custom.downtimeCommentData being the component bound by a query.  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/f/bf78c5d203086848d27513c3d608f815bcea157c.png)

Message sent :  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/6/a69820d0790a296fbb7eee708664933c1502fd77.png)

Message handler :  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/8/c87d6ddb3d1ea911dd7dc0a9ddb73f13f7b161c1.png)

Polling the data at a set interval works to get the data, but I would prefer to have a more concrete solution (polling causes graphical glitches in the view)

---

<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:** [May 18, 2023, 6:30pm UTC](https://forum.inductiveautomation.com/t/query-binding-not-refreshing-with-the-refreshbinding-command/73917/2 "2023-05-18T18:30:31Z")

</div>

If I understand correctly, you update a query record with a button which also triggers another query that reads the same record to verify the contents were modified? Maybe the read query is reading the record before the update is completed?

---

<div class="post-metadata">

**Author:** ![Charles\_Belanger](https://avatars.discourse-cdn.com/v4/letter/c/5fc32e/32.png) [@Charles\_Belanger](https://forum.inductiveautomation.com/u/Charles_Belanger)\
**Post date:** [May 18, 2023, 6:35pm UTC](https://forum.inductiveautomation.com/t/query-binding-not-refreshing-with-the-refreshbinding-command/73917/3 "2023-05-18T18:35:30Z")

</div>

While I do believe this could be the case, there is some code that checks for a return value from the sending call to the DB before sending the message.  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/e/8e3be2d5e1440324713cb52d472a2bb68a916e23.png)

For more information, it seems the query does read after writing a comment and clicking the button, but it is always one query short (so if I write "1", nothing appears. Then, if I write "2", "1" appears, etc.)

---

<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:** [May 18, 2023, 6:41pm UTC](https://forum.inductiveautomation.com/t/query-binding-not-refreshing-with-the-refreshbinding-command/73917/4 "2023-05-18T18:41:17Z")

</div>

I don't think a message handler is needed here. Try replacing the `sendMessage` lines with something like this, or whatever the component path is.

```auto
self.getSibling("component").refreshBinding("custom.downtimeCommentData")

```

---

<div class="post-metadata">

**Author:** ![Charles\_Belanger](https://avatars.discourse-cdn.com/v4/letter/c/5fc32e/32.png) [@Charles\_Belanger](https://forum.inductiveautomation.com/u/Charles_Belanger)\
**Post date:** [May 19, 2023, 12:57pm UTC](https://forum.inductiveautomation.com/t/query-binding-not-refreshing-with-the-refreshbinding-command/73917/5 "2023-05-19T12:57:46Z")

</div>

Just putting a delay (sleep()) before refreshing seems to do the trick.

```auto
	from time import sleep

	sleep(1)
	self.refreshBinding("custom.downtimeCommentData")

```
