# Setting template (repeater) parameters from a template script within

**URL:** <https://forum.inductiveautomation.com/t/setting-template-repeater-parameters-from-a-template-script-within/94041>\
**Category:** Ignition\
**Tags:** scripting\
**Created:** [August 1, 2024, 1:48pm UTC](https://forum.inductiveautomation.com/t/setting-template-repeater-parameters-from-a-template-script-within/94041 "2024-08-01T13:48:15Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kevin\_VR](https://avatars.discourse-cdn.com/v4/letter/k/7ab992/32.png) [@Kevin\_VR](https://forum.inductiveautomation.com/u/Kevin_VR)\
**Post date:** [August 1, 2024, 1:48pm UTC](https://forum.inductiveautomation.com/t/setting-template-repeater-parameters-from-a-template-script-within/94041/1 "2024-08-01T13:48:15Z")

</div>

Hi, I'm trying to pass a string (buttonText) that is stored inside a template to its parent (template repeater) by storing it in a custom property called selectedButton. It is only allowed to pass it if active == True (active is a property of the template). The mouseClicked event triggers it.

```python

component = event.source
parentComponent = component.parent

if component.getPropertyValue('active'):
	parentComponent.selectedButton = component.getPropertyValue('buttonText')

```

The shown code results in the following error: object has no attribute 'selectedButton'.

Would be appreciated if somebody could help me out, many thanks!  
Kevin

---

<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 1, 2024, 2:33pm UTC](https://forum.inductiveautomation.com/t/setting-template-repeater-parameters-from-a-template-script-within/94041/2 "2024-08-01T14:33:35Z")

</div>

The direct parent of a template instance won't be the containing component - there's more intermediaries than that, for boring technical reasons. Try printing the type of each parent reference you get as you add more successive `.parent` calls until you get the repeater.

---

<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:** [August 1, 2024, 2:50pm UTC](https://forum.inductiveautomation.com/t/setting-template-repeater-parameters-from-a-template-script-within/94041/3 "2024-08-01T14:50:37Z")

</div>

Historically, it has been `.parent.parent` to get to a simple template holder from its template root, and `.parent.parent.parent` to get to either a repeater or canvas from that template root.

---

<div class="post-metadata">

**Author:** ![Kevin\_VR](https://avatars.discourse-cdn.com/v4/letter/k/7ab992/32.png) [@Kevin\_VR](https://forum.inductiveautomation.com/u/Kevin_VR)\
**Post date:** [August 2, 2024, 7:10am UTC](https://forum.inductiveautomation.com/t/setting-template-repeater-parameters-from-a-template-script-within/94041/4 "2024-08-02T07:10:08Z")

</div>

That's very interesting and insightful to know. I wasn't aware of the amount of component layers inside the template canvas. My issue has been resolved thanks to your help, PGriffith and pturmel!

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [August 2, 2024, 3:54pm UTC](https://forum.inductiveautomation.com/t/setting-template-repeater-parameters-from-a-template-script-within/94041/5 "2024-08-02T15:54:56Z")

</div>

I haven't used the `.parent.parent.parent.parent...` approach in a long time. I prefer to use either `system.gui.getParentWindow(event)...` or `SwingUtilities.getAncestorOfClass...`.
