# Apply Polling rate on named query called upon from radio button selected value

**URL:** <https://forum.inductiveautomation.com/t/apply-polling-rate-on-named-query-called-upon-from-radio-button-selected-value/70653>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [March 6, 2023, 9:33am UTC](https://forum.inductiveautomation.com/t/apply-polling-rate-on-named-query-called-upon-from-radio-button-selected-value/70653 "2023-03-06T09:33:02Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bhavik\_Patel](https://avatars.discourse-cdn.com/v4/letter/b/d78d45/32.png) [@Bhavik\_Patel](https://forum.inductiveautomation.com/u/Bhavik_Patel)\
**Post date:** [March 6, 2023, 9:33am UTC](https://forum.inductiveautomation.com/t/apply-polling-rate-on-named-query-called-upon-from-radio-button-selected-value/70653/1 "2023-03-06T09:33:02Z")

</div>

I have multiple Name queries and I want to run them as value selected from Radio button. I could achieve this by property binding to that radio button, but the named query is not updating every 30 seconds, I am not able to apply polling rate here. I tried various approaches  
like 1.) runScript(system.db.runNamedQuery()),  
2.) import time  
while True:  
runNamedQuery('')  
time.sleep(30)

but both are not working

My Expected outcome should be:

if radioButtonValue == x:  
runNamedQuery("Query1")  
elif radioButonValue == y:  
runNamedQuery("Query2")  
else  
runNamedQuery("Query3")

Where return should be apply every 30 seconds.

Please help me how can I achieve this?

---

<div class="post-metadata">

**Author:** ![Alex\_Leech](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alex_leech/32/39391_2.png) [@Alex\_Leech](https://forum.inductiveautomation.com/u/Alex_Leech)\
**Post date:** [March 6, 2023, 11:21am UTC](https://forum.inductiveautomation.com/t/apply-polling-rate-on-named-query-called-upon-from-radio-button-selected-value/70653/2 "2023-03-06T11:21:57Z")

</div>

Hiya,

This probably isnt the most efficient approach, but if the query is to select data (which I assume it is seeing as your polling), then you could create three different custom props on the root object, each with the named query binding set to poll at 30 seconds (hence not efficient as its polling all three), and then based on the radio button state, show the data from either prop 1, 2 or 3.

Alex

---

<div class="post-metadata">

**Author:** ![Bhavik\_Patel](https://avatars.discourse-cdn.com/v4/letter/b/d78d45/32.png) [@Bhavik\_Patel](https://forum.inductiveautomation.com/u/Bhavik_Patel)\
**Post date:** [March 6, 2023, 12:11pm UTC](https://forum.inductiveautomation.com/t/apply-polling-rate-on-named-query-called-upon-from-radio-button-selected-value/70653/3 "2023-03-06T12:11:57Z")

</div>

Thanks Alex for feedback. But Unfortunately I cannot apply/bind directly 3 unique named query to root object, As I have created one flex repeater panel, based on radio root object selector, all I want to update it in all instances of flex repeater object. So ultimately I have total no of named query are:  
3 \* no of flex repeater instances

I hope you get me.

Can we somehow do coding on Radio button that every 30 secs, the selected value rebind or else?

---

<div class="post-metadata">

**Author:** ![Alex\_Leech](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alex_leech/32/39391_2.png) [@Alex\_Leech](https://forum.inductiveautomation.com/u/Alex_Leech)\
**Post date:** [March 6, 2023, 12:20pm UTC](https://forum.inductiveautomation.com/t/apply-polling-rate-on-named-query-called-upon-from-radio-button-selected-value/70653/4 "2023-03-06T12:20:59Z")

</div>

I'll admit I dont fully understand, but I think what you need to use is a gateway script, as with these you can do timed execution.

You could perhaps use the gateway timed script to send a message to a 'radioButtonUpdate' message handler every 30 seconds.  
Then the radio button component could listen for that message and perform its update when it recieves it?

> **[Timer Scripts Video at Inductive University](https://inductiveuniversity.com/videos/timer-scripts/8.1)**
>
> Learn how to write Gateway and Client scripts that execute on a timer.

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [March 6, 2023, 12:26pm UTC](https://forum.inductiveautomation.com/t/apply-polling-rate-on-named-query-called-upon-from-radio-button-selected-value/70653/5 "2023-03-06T12:26:44Z")

</div>

Create a custom property to hold your query result.

Create an expression binding of:

```auto
now(30000)

```

Add a script transform to look at the value of the radio group's index.

```python
if radioButton.index == 0:
    return system.db.runNamedQuery('Query1')
elif radioButton.index == 1:
    return system.db.runNamedQuery('Query2')
else:
    return system.db.runNamedQuery('Query3')

```

Are you expecting the data to change? If not there really isn't a reason for it to be polling.

---

<div class="post-metadata">

**Author:** ![Bhavik\_Patel](https://avatars.discourse-cdn.com/v4/letter/b/d78d45/32.png) [@Bhavik\_Patel](https://forum.inductiveautomation.com/u/Bhavik_Patel)\
**Post date:** [March 24, 2023, 7:38am UTC](https://forum.inductiveautomation.com/t/apply-polling-rate-on-named-query-called-upon-from-radio-button-selected-value/70653/6 "2023-03-24T07:38:08Z")

</div>

Thanks @lrose This suggestion worked for me. Thanks again!
