# How to display the different values for all template repeaters on clicking on one Button

**URL:** <https://forum.inductiveautomation.com/t/how-to-display-the-different-values-for-all-template-repeaters-on-clicking-on-one-button/75196>\
**Category:** General Discussion\
**Tags:** scripting, perspective\
**Created:** [June 19, 2023, 8:51am UTC](https://forum.inductiveautomation.com/t/how-to-display-the-different-values-for-all-template-repeaters-on-clicking-on-one-button/75196 "2023-06-19T08:51:05Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![kavya\_shree](https://avatars.discourse-cdn.com/v4/letter/k/b4bc9f/32.png) [@kavya\_shree](https://forum.inductiveautomation.com/u/kavya_shree)\
**Post date:** [June 19, 2023, 8:51am UTC](https://forum.inductiveautomation.com/t/how-to-display-the-different-values-for-all-template-repeaters-on-clicking-on-one-button/75196/1 "2023-06-19T08:51:05Z")

</div>

Hi,  
we have 5 machines, for all machines we need to show total good parts for different timings on clicking on button. values are coming from PLC and storing it in DB for 15 mins.  
here is my template, I binded this for named query for 30 mins.

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

Here is my main View,  
I can use multistate button or single button for different timings. by clicking on button, value should change in all machine fields(TextField)

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

please guide

---

<div class="post-metadata">

**Author:** ![Hayden\_Watson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/hayden_watson/32/48792_2.png) [@Hayden\_Watson](https://forum.inductiveautomation.com/u/Hayden_Watson)\
**Post date:** [June 19, 2023, 9:21am UTC](https://forum.inductiveautomation.com/t/how-to-display-the-different-values-for-all-template-repeaters-on-clicking-on-one-button/75196/2 "2023-06-19T09:21:10Z")

</div>

Can you not set a parameter in your named query, for the 'inputMin' and machine name. And just put the minutes parameter, etc. in there?

---

<div class="post-metadata">

**Author:** ![kavya\_shree](https://avatars.discourse-cdn.com/v4/letter/k/b4bc9f/32.png) [@kavya\_shree](https://forum.inductiveautomation.com/u/kavya_shree)\
**Post date:** [June 19, 2023, 10:07am UTC](https://forum.inductiveautomation.com/t/how-to-display-the-different-values-for-all-template-repeaters-on-clicking-on-one-button/75196/3 "2023-06-19T10:07:51Z")

</div>

here is my SQL query for 60min, so I can change it for 30,80 and so on.  
On clicking on 30 mins Button it should change for all machines.

```auto
DECLARE @currentdttm datetime 
DECLARE @inputMin int
SET @inputMin = 60
SET @currentdttm = SWITCHOFFSET(SYSDATETIMEOFFSET(), '+05:30')

 

SELECT DateTime,TOTALGOODPARTS 
FROM ROUGHER_PLC_DB  
WHERE DateTime < @currentdttm
AND DateTime > dateadd(minute, -@inputMin, @currentdttm)

 

 

declare @MinHours TABLE(
S_NO int IDENTITY(1,1),
Date_Time datetime,
TOTALGOODPARTS_Min int,
hour_min int
)
declare @MaxHours TABLE(
S_NO int IDENTITY(1,1),
Date_Time datetime,
TOTALGOODPARTS_Max int,
hour_max int
)
BEGIN

 

    BEGIN
    INSERT INTO @MinHours
        select TOP 1 DateTime,TOTALGOODPARTS,HOUR from ROUGHER_PLC_DB 
        where 1=1
        AND DateTime < @currentdttm
        AND DateTime > dateadd(minute, -@inputMin, @currentdttm) 
        order by DateTime asc
    END

 

    BEGIN
    INSERT INTO @MaxHours
        select TOP 1 DateTime,TOTALGOODPARTS,HOUR from ROUGHER_PLC_DB 
        where 1=1
        AND DateTime < @currentdttm
        AND DateTime > dateadd(minute, -@inputMin, @currentdttm)
        order by DateTime desc
    END
END
--Select * from @MinHours;
-- Select * from @MaxHours;
select MAX.Date_Time as MAX_TIME,MIN.Date_Time as MIN_TIME,MAX.TOTALGOODPARTS_Max - MIN.TOTALGOODPARTS_Min as GOOD_PARTS
from @MaxHours MAX 
INNER JOIN @MinHours MIN
ON MAX.S_NO = MIN.S_NO

```

---

<div class="post-metadata">

**Author:** ![Hayden\_Watson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/hayden_watson/32/48792_2.png) [@Hayden\_Watson](https://forum.inductiveautomation.com/u/Hayden_Watson)\
**Post date:** [June 19, 2023, 10:28am UTC](https://forum.inductiveautomation.com/t/how-to-display-the-different-values-for-all-template-repeaters-on-clicking-on-one-button/75196/4 "2023-06-19T10:28:29Z")

</div>

If the only thing you change is the variables at the top you could set a paramter in the named query and put

```auto
@inputMin = :newValue1

```

etc.

for example

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/4/24f9c132e80b189439e88176600f2aae34e332da.png)

In the binding on your repeated view, put your parameter into this value

---

<div class="post-metadata">

**Author:** ![kavya\_shree](https://avatars.discourse-cdn.com/v4/letter/k/b4bc9f/32.png) [@kavya\_shree](https://forum.inductiveautomation.com/u/kavya_shree)\
**Post date:** [June 19, 2023, 10:59am UTC](https://forum.inductiveautomation.com/t/how-to-display-the-different-values-for-all-template-repeaters-on-clicking-on-one-button/75196/5 "2023-06-19T10:59:48Z")

</div>

ok I will try. thanks

---

<div class="post-metadata">

**Author:** ![kavya\_shree](https://avatars.discourse-cdn.com/v4/letter/k/b4bc9f/32.png) [@kavya\_shree](https://forum.inductiveautomation.com/u/kavya_shree)\
**Post date:** [June 19, 2023, 11:21am UTC](https://forum.inductiveautomation.com/t/how-to-display-the-different-values-for-all-template-repeaters-on-clicking-on-one-button/75196/6 "2023-06-19T11:21:40Z")

</div>

please can you check this , is it correct, Sorry I am not getting how it will work on clicking on button,  
Please guide

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

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [June 19, 2023, 3:21pm UTC](https://forum.inductiveautomation.com/t/how-to-display-the-different-values-for-all-template-repeaters-on-clicking-on-one-button/75196/7 "2023-06-19T15:21:18Z")

</div>

> [@Hayden\_Watson](#):
>
> ```auto
> @inputMin = :newValue1
> 
> ```

Ewww! Don't do that. That is not JDBC compliant, and is only likely to work on SQL Server. Just put the colon-delimited parameters where appropriate.

---

<div class="post-metadata">

**Author:** ![kavya\_shree](https://avatars.discourse-cdn.com/v4/letter/k/b4bc9f/32.png) [@kavya\_shree](https://forum.inductiveautomation.com/u/kavya_shree)\
**Post date:** [June 20, 2023, 3:49am UTC](https://forum.inductiveautomation.com/t/how-to-display-the-different-values-for-all-template-repeaters-on-clicking-on-one-button/75196/8 "2023-06-20T03:49:04Z")

</div>

sorry, I am not getting.  
Can you please guide how I can bind it and on Button.  
you can find my screen in attachment.  
[Template\_View\_values.zip](https://forum.inductiveautomation.com/uploads/short-url/f2Ni7jUkK9vxjfvCgrQmPJKtELL.zip) (52.7 KB)
