# Repeater.getLoadedTemplates()

**URL:** <https://forum.inductiveautomation.com/t/repeater-getloadedtemplates/11422>\
**Category:** Ignition\
**Created:** [March 28, 2016, 2:12am UTC](https://forum.inductiveautomation.com/t/repeater-getloadedtemplates/11422 "2016-03-28T02:12:55Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![cmisztur2](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmisztur2/32/4243_2.png) [@cmisztur2](https://forum.inductiveautomation.com/u/cmisztur2)\
**Post date:** [March 28, 2016, 2:12am UTC](https://forum.inductiveautomation.com/t/repeater-getloadedtemplates/11422/1 "2016-03-28T02:12:55Z")

</div>

I have a template with a repeater that repeats a custom button template.  
The parent template's custom property is bound to a tag.  
The repeater's templateParams, inside the parent template, is bound to a SQL query.  
Once the SQL executes and repeats my custom button template, I need to toggle the first button.

What I have tried is to execute a script when the repeater's templateParams changes.

However at this point, getLoadedTemplates() returns an empty array.

Is there a different approach to this?

[code]  
PROPERTY\_CHANGE::(VisionTemplate)[ToggleStrip].[AssetId] 0 =\> 3  
PROPERTY\_CHANGE::(TemplateRepeater)[repeater].[templateParams] Dataset [0R ⅹ 3C] =\> Dataset [4R ⅹ 3C]

> > > > getLoadedTemplates executed here  
> > > > PROPERTY\_CHANGE::(VisionTemplate)[ToggleStripButton].[componentRunning] False =\> True  
> > > > PROPERTY\_CHANGE::(VisionTemplate)[ToggleStripButton].[instanceName] =\> repeater\_child\_0  
> > > > PROPERTY\_CHANGE::(VisionTemplate)[ToggleStripButton].[Text] =\> Job  
> > > > PROPERTY\_CHANGE::(VisionTemplate)[ToggleStripButton].[WindowName] =\> jde/CollectWorkOrderAndOperation  
> > > > PROPERTY\_CHANGE::(VisionTemplate)[ToggleStripButton].[AssetId] 0 =\> 3  
> > > > PROPERTY\_CHANGE::(VisionTemplate)[ToggleStripButton].[componentRunning] False =\> True  
> > > > PROPERTY\_CHANGE::(VisionTemplate)[ToggleStripButton].[instanceName] =\> repeater\_child\_1  
> > > > PROPERTY\_CHANGE::(VisionTemplate)[ToggleStripButton].[index] 0 =\> 1  
> > > > PROPERTY\_CHANGE::(VisionTemplate)[ToggleStripButton].[Text] =\> Material  
> > > > PROPERTY\_CHANGE::(VisionTemplate)[ToggleStripButton].[WindowName] =\> communication/MaterialHandlerRequest  
> > > > PROPERTY\_CHANGE::(VisionTemplate)[ToggleStripButton].[AssetId] 0 =\> 3  
> > > > PROPERTY\_CHANGE::(VisionTemplate)[ToggleStripButton].[componentRunning] False =\> True  
> > > > PROPERTY\_CHANGE::(VisionTemplate)[ToggleStripButton].[instanceName] =\> repeater\_child\_2  
> > > > PROPERTY\_CHANGE::(VisionTemplate)[ToggleStripButton].[index] 0 =\> 2  
> > > > PROPERTY\_CHANGE::(VisionTemplate)[ToggleStripButton].[Text] =\> Tests  
> > > > PROPERTY\_CHANGE::(VisionTemplate)[ToggleStripButton].[WindowName] =\> workcenters/TorqueTesterFixture  
> > > > PROPERTY\_CHANGE::(VisionTemplate)[ToggleStripButton].[AssetId] 0 =\> 3  
> > > > PROPERTY\_CHANGE::(VisionTemplate)[ToggleStripButton].[componentRunning] False =\> True  
> > > > PROPERTY\_CHANGE::(VisionTemplate)[ToggleStripButton].[instanceName] =\> repeater\_child\_3  
> > > > PROPERTY\_CHANGE::(VisionTemplate)[ToggleStripButton].[index] 0 =\> 3  
> > > > PROPERTY\_CHANGE::(VisionTemplate)[ToggleStripButton].[Text] =\> Calibration  
> > > > PROPERTY\_CHANGE::(VisionTemplate)[ToggleStripButton].[WindowName] =\> workcenters/TorqueTesterFixtureCalibration  
> > > > PROPERTY\_CHANGE::(VisionTemplate)[ToggleStripButton].[AssetId] 0 =\> 3[/code]

---

<div class="post-metadata">

**Author:** ![cmisztur2](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmisztur2/32/4243_2.png) [@cmisztur2](https://forum.inductiveautomation.com/u/cmisztur2)\
**Post date:** [March 28, 2016, 2:39am UTC](https://forum.inductiveautomation.com/t/repeater-getloadedtemplates/11422/2 "2016-03-28T02:39:29Z")

</div>

Meh, so instead I am watching the “instanceName” property of the child template.  
When I see a change, I call a function on the parent template which increments an internal property.  
When that internal property == repeater’s templateParams, then I execute a ‘onTemplateReady’ function where I can use getLoadedTemplates().

Seems to work ok.

---

<div class="post-metadata">

**Author:** ![iamcoder](https://avatars.discourse-cdn.com/v4/letter/i/5f9b8f/32.png) [@iamcoder](https://forum.inductiveautomation.com/u/iamcoder)\
**Post date:** [September 6, 2016, 8:16am UTC](https://forum.inductiveautomation.com/t/repeater-getloadedtemplates/11422/3 "2016-09-06T08:16:25Z")

</div>

do you have sample code sir?

---

<div class="post-metadata">

**Author:** ![cmisztur2](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmisztur2/32/4243_2.png) [@cmisztur2](https://forum.inductiveautomation.com/u/cmisztur2)\
**Post date:** [September 28, 2017, 2:20pm UTC](https://forum.inductiveautomation.com/t/repeater-getloadedtemplates/11422/4 "2017-09-28T14:20:32Z")

</div>

![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/0/068bccb2648fb57c668ca9d1852f470c356d2927.png)

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/3/3985688664cf6ee276d9c663ed4722144d48298a.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:** [September 28, 2017, 4:45pm UTC](https://forum.inductiveautomation.com/t/repeater-getloadedtemplates/11422/5 "2017-09-28T16:45:38Z")

</div>

This might be a good place to use [`system.util.invokeLater`](https://docs.inductiveautomation.com/display/DOC79/system.util.invokeLater)?

I can’t remember if template loading is synchronous (probably) so invokeLater should put your actions after the template loading in the EDT.

---

<div class="post-metadata">

**Author:** ![cmisztur2](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmisztur2/32/4243_2.png) [@cmisztur2](https://forum.inductiveautomation.com/u/cmisztur2)\
**Post date:** [September 29, 2017, 8:28pm UTC](https://forum.inductiveautomation.com/t/repeater-getloadedtemplates/11422/6 "2017-09-29T20:28:40Z")

</div>

Question, how would you do this from a Client Message Handler?

My example:

- window with a repeater, repeatBehavior=Count
- Window.internalFrame.internalFrameActivated call system.util.sendMessage
- Inside the message handler, find the repeater and call getLoadedTemplates()

I tried different threading models for the message handler and I also tried invokeLater within the message handler. None worked.
