# Access a custom method of a template from a other window

**URL:** <https://forum.inductiveautomation.com/t/access-a-custom-method-of-a-template-from-a-other-window/46947>\
**Category:** Ignition\
**Created:** [May 20, 2021, 4:53pm UTC](https://forum.inductiveautomation.com/t/access-a-custom-method-of-a-template-from-a-other-window/46947 "2021-05-20T16:53:36Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![lachguerabdallah](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lachguerabdallah/32/25558_2.png) [@lachguerabdallah](https://forum.inductiveautomation.com/u/lachguerabdallah)\
**Post date:** [May 20, 2021, 4:53pm UTC](https://forum.inductiveautomation.com/t/access-a-custom-method-of-a-template-from-a-other-window/46947/1 "2021-05-20T16:53:36Z")

</div>

Hello, how can I access a custom method of a template from a other window?

I have tried doing this:

```auto

window = system.gui.getWindow('example')

template = window.getRootContainer().getComponent('templateName')
 
#addPen= custom methode
template.getComponent(0).parent.addPen()

```

thanks you

---

<div class="post-metadata">

**Author:** ![jespinmartin1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jespinmartin1/32/57175_2.png) [@jespinmartin1](https://forum.inductiveautomation.com/u/jespinmartin1)\
**Post date:** [May 20, 2021, 5:38pm UTC](https://forum.inductiveautomation.com/t/access-a-custom-method-of-a-template-from-a-other-window/46947/2 "2021-05-20T17:38:05Z")

</div>

Do you mean a custom property?  
To get the value of custom property you can do:

```auto
windowPath = "Main Window"
templateName = "myTemplate"
parameterName = 'myParameter' 
window = system.gui.getWindow(windowPath)
template = window.getRootContainer().getComponent(templateName)
parameterValue = template.getParameterValues()[parameterName]

```

Make sure that the window where your template is located to stay open, otherwise you’ll get an error.

---

<div class="post-metadata">

**Author:** ![lachguerabdallah](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lachguerabdallah/32/25558_2.png) [@lachguerabdallah](https://forum.inductiveautomation.com/u/lachguerabdallah)\
**Post date:** [May 20, 2021, 5:53pm UTC](https://forum.inductiveautomation.com/t/access-a-custom-method-of-a-template-from-a-other-window/46947/3 "2021-05-20T17:53:02Z")

</div>

Hello @jespinmartin1 i mean a custom function, no a custom property

---

<div class="post-metadata">

**Author:** ![jespinmartin1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jespinmartin1/32/57175_2.png) [@jespinmartin1](https://forum.inductiveautomation.com/u/jespinmartin1)\
**Post date:** [May 20, 2021, 6:00pm UTC](https://forum.inductiveautomation.com/t/access-a-custom-method-of-a-template-from-a-other-window/46947/4 "2021-05-20T18:00:47Z")

</div>

That sound confusing, What do you mean by “to access”? Do you want to execute the custom method by some listener or extract the code as string?

To trigger the method you can add a property to the template as a trigger like:

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

each time you wish to execute the method pass a true value

---

<div class="post-metadata">

**Author:** ![lachguerabdallah](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lachguerabdallah/32/25558_2.png) [@lachguerabdallah](https://forum.inductiveautomation.com/u/lachguerabdallah)\
**Post date:** [May 21, 2021, 10:06am UTC](https://forum.inductiveautomation.com/t/access-a-custom-method-of-a-template-from-a-other-window/46947/5 "2021-05-21T10:06:27Z")

</div>

> [@jespinmartin1](#):
>
> ```auto
> windowPath = "Main Window"
> templateName = "myTemplate"
> parameterName = 'myParameter' 
> window = system.gui.getWindow(windowPath)
> template = window.getRootContainer().getComponent(templateName)
> parameterValue = template.getParameterValues()[parameterName]
> 
> ```

Thank you. I have tried doing it this way and it works perfectly.
