# Detect Loading Data from Named Query

**URL:** <https://forum.inductiveautomation.com/t/detect-loading-data-from-named-query/49904>\
**Category:** Ignition\
**Created:** [August 13, 2021, 3:51pm UTC](https://forum.inductiveautomation.com/t/detect-loading-data-from-named-query/49904 "2021-08-13T15:51:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rrebro](https://avatars.discourse-cdn.com/v4/letter/r/3da27b/32.png) [@rrebro](https://forum.inductiveautomation.com/u/rrebro)\
**Post date:** [August 13, 2021, 3:51pm UTC](https://forum.inductiveautomation.com/t/detect-loading-data-from-named-query/49904/1 "2021-08-13T15:51:15Z")

</div>

I have a series of charts with data feeding in from named queries with a variable parameter for the timeframe of data to use. When grabbing data large enough, the charts remain blank while the named queries are populating the charts, ~10-20 seconds. Is there a way to detect this such that I can have a loading animation for the user to know things are still loading?

---

<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 13, 2021, 4:31pm UTC](https://forum.inductiveautomation.com/t/detect-loading-data-from-named-query/49904/2 "2021-08-13T16:31:08Z")

</div>

Vision or Perspective? What triggers the execution of these named queries?

---

<div class="post-metadata">

**Author:** ![rrebro](https://avatars.discourse-cdn.com/v4/letter/r/3da27b/32.png) [@rrebro](https://forum.inductiveautomation.com/u/rrebro)\
**Post date:** [August 13, 2021, 5:14pm UTC](https://forum.inductiveautomation.com/t/detect-loading-data-from-named-query/49904/3 "2021-08-13T17:14:49Z")

</div>

This is in Vision. One of the parameters in the named query changes. In my case it is a Starting date.

---

<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 13, 2021, 5:23pm UTC](https://forum.inductiveautomation.com/t/detect-loading-data-from-named-query/49904/4 "2021-08-13T17:23:09Z")

</div>

So, we don't provide any ability to 'introspect' the bindings and know that they're in progress. What you can do instead of bindings is issue your named query from scripting; you'll want to wire up the appropriate `propertyChange` scripting events to fire your script, _but_ if you do that then you'll be able to set some 'loading' flag (and react to that in your UI accordingly) and then, _in a background thread_, execute your named query (and then jump back to the EDT to deliver the results).  
It's an immediate, significant jump in complexity, unfortunately, but is the best way to get what you want.  
@pturmel wrote a scripting module, `later.py`, that helps a lot with the 'boilerplate' around running an async task and returning results on the main thread:

> [@Update GUI via Asynchronous thread](https://forum.inductiveautomation.com/t/update-gui-via-asynchronous-thread/9666/3):
>
> Since this sort of thing pops up often, I created a set of wrappers that simplify this stuff, and allows you to directly use functions in your script modules. The wrappers take care of stuffing the arguments you supply into a temporary fuction’s default argument. For your case, try assignLater(). Nick’s example becomes: # In a script module in your project: import shutil def fileTransfer(label): path = system.file.openFile() newPath = "F:\NewFolder" shutil.copy2(path, newPath) sh…
