# Accessing Custom Methods in Nested Templates?

**URL:** <https://forum.inductiveautomation.com/t/accessing-custom-methods-in-nested-templates/54941>\
**Category:** Ignition\
**Tags:** ignition81, vision\
**Created:** [January 12, 2022, 5:44pm UTC](https://forum.inductiveautomation.com/t/accessing-custom-methods-in-nested-templates/54941 "2022-01-12T17:44:11Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mschell1978](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mschell1978/32/8996_2.png) [@mschell1978](https://forum.inductiveautomation.com/u/mschell1978)\
**Post date:** [January 12, 2022, 5:44pm UTC](https://forum.inductiveautomation.com/t/accessing-custom-methods-in-nested-templates/54941/1 "2022-01-12T17:44:11Z")

</div>

How do you call custom methods in nested templates from scripts within the root container?  
For example assume method ‘myMethod()’ on template ‘Template B’. Template B is contained within another template, ‘Template A’.  
(e.g. Root Container → Template A → Template B).

I can obtain a reference to Template B from the root, but I can not call the method ‘myMethod()’ on that template. Using ‘hasattr’ also shows that the method is not present (it is not a member of ‘Template Holder’ nor ‘Vision Template’).

However, if Template B is not nested within another template I can obtain a reference where the method exists and is callable (even if it is nested inside another component, like a container).

Thoughts on why this is so and how to work around this?

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [January 12, 2022, 5:49pm UTC](https://forum.inductiveautomation.com/t/accessing-custom-methods-in-nested-templates/54941/2 "2022-01-12T17:49:07Z")

</div>

Put whatever script you have into the scripting module section of your project and call it directly from there. I think you probably can drill down and get it eventually by doing `.getComponent(0)` on the template instance itself to get the actual properties/custom methods you have attached.

But I think a much cleaner way would be to put your script into the script modules and just call it from there instead.

I have yet to find a use case where a custom method on a component is preferable to calling the same script from the project library.

---

<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:** [January 12, 2022, 5:51pm UTC](https://forum.inductiveautomation.com/t/accessing-custom-methods-in-nested-templates/54941/3 "2022-01-12T17:51:42Z")

</div>

Install Simulation Aids. Then it will work.

See this (deep) discussion for why:

> [@Transaction groups triggered expression item updating when trigger is false](https://forum.inductiveautomation.com/t/transaction-groups-triggered-expression-item-updating-when-trigger-is-false/17196/15):
>
> Thank you very much for the quick fix. Been testing this new beta on a few use cases and haven’t issued any gotchas yet slight_smile

---

<div class="post-metadata">

**Author:** ![mschell1978](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mschell1978/32/8996_2.png) [@mschell1978](https://forum.inductiveautomation.com/u/mschell1978)\
**Post date:** [January 12, 2022, 6:15pm UTC](https://forum.inductiveautomation.com/t/accessing-custom-methods-in-nested-templates/54941/4 "2022-01-12T18:15:37Z")

</div>

Works perfectly now. Thanks!

---

<div class="post-metadata">

**Author:** ![bmusson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bmusson/32/87530_2.png) [@bmusson](https://forum.inductiveautomation.com/u/bmusson)\
**Post date:** [June 2, 2022, 8:05pm UTC](https://forum.inductiveautomation.com/t/accessing-custom-methods-in-nested-templates/54941/5 "2022-06-02T20:05:48Z")

</div>

> [@Transaction groups triggered expression item updating when trigger is false](https://forum.inductiveautomation.com/t/transaction-groups-triggered-expression-item-updating-when-trigger-is-false/17196/19):
>
> ... when IA adds this functionality to the base install. 😁

Is there any chance of getting this `PyComponentAdapter`-fix-thing into base Ignition?

I was banging my head against the wall for the last hour trying to call custom methods on nested templates, only to find out it's not possible because of a wacky limitation.

I've got no issues running with Phil's Simulation Aids, but this whole situation seems like a bug.

---

<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:** [June 2, 2022, 9:06pm UTC](https://forum.inductiveautomation.com/t/accessing-custom-methods-in-nested-templates/54941/6 "2022-06-02T21:06:23Z")

</div>

It’s been a low priority backlog item for a while, just hasn’t gotten to the top of the pile. I registered some additional demand based on this thread.
