# How to access Template Canvas property in instance

**URL:** <https://forum.inductiveautomation.com/t/how-to-access-template-canvas-property-in-instance/32908>\
**Category:** Ignition\
**Tags:** ignition80\
**Created:** [March 7, 2020, 9:24am UTC](https://forum.inductiveautomation.com/t/how-to-access-template-canvas-property-in-instance/32908 "2020-03-07T09:24:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Neo](https://avatars.discourse-cdn.com/v4/letter/n/9fc348/32.png) [@Neo](https://forum.inductiveautomation.com/u/Neo)\
**Post date:** [March 7, 2020, 9:24am UTC](https://forum.inductiveautomation.com/t/how-to-access-template-canvas-property-in-instance/32908/1 "2020-03-07T09:24:15Z")

</div>

I am using a template canvas with multiple template instances in it. I would like to access the properties of this template canvas on click of button inside the instance. Currently, I am using following code to access the template canvas and then its properties:

```auto
templateCanvas = system.gui.getParentWindow(event).getRootContainer().getComponent(templateCanvasName)
property = templateCanvas.propertyName

```

while it is working fine, it will break if the template canvas is moved inside another container. To circumvent this issue, passing the absolute path of template canvas to template instances through templates dataset property is one of the options I can think of.

But is there any other way to get the reference of template canvas without using the name? something similar to `event.source.parent.parent`?

---

<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:** [March 7, 2020, 2:50pm UTC](https://forum.inductiveautomation.com/t/how-to-access-template-canvas-property-in-instance/32908/2 "2020-03-07T14:50:32Z")

</div>

> [@Neo](#):
>
> something similar to `event.source.parent.parent` ?

Exactly that, though you'll have to experiment to get the right number of .parent references (depends on canvas vs. repeater vs. single instance holder).

---

<div class="post-metadata">

**Author:** ![Neo](https://avatars.discourse-cdn.com/v4/letter/n/9fc348/32.png) [@Neo](https://forum.inductiveautomation.com/u/Neo)\
**Post date:** [March 10, 2020, 2:29pm UTC](https://forum.inductiveautomation.com/t/how-to-access-template-canvas-property-in-instance/32908/3 "2020-03-10T14:29:44Z")

</div>

Using `event.source.parent` on template instance, I can access all properties of the instance in template canvas. However interesting thing is, `event.source.parent.parent.name` gives `None`, `event.source.parent.parent.x or y` returns 0 but `event.source.parent.parent.width or height` gives me correct values of template canvas width/height. Also, using `event.source.parent.parent` to access custom properties or other properties like templates of template canvas throws error.  
I am curious which component it is referencing by `event.source.parent.parent`? and how this hierarchy works?

---

<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:** [March 10, 2020, 2:58pm UTC](https://forum.inductiveautomation.com/t/how-to-access-template-canvas-property-in-instance/32908/4 "2020-03-10T14:58:12Z")

</div>

Try `print type(event.source.parent.parent)` (and so on) if you’re curious about the internals.  
Basically, when actually embedded in a window, templates have to be ‘embedded’ inside of a (normally transparent to the designer) `TemplateHolder` object. There’s complicated reasons for this, but we generally try to hide it from you; except when you’re doing scripting like this, where we really can’t. As Phil mentioned, when using the template repeater or canvas you’ll even need additional `.parent` calls, due to the way those components have to do their own layout.
