Accessing templates from another template

I have many instances of one template on my form. Each instance represents an hour of a shift with data such as completed parts. I am trying to keep a running total of completed parts from each hour. So I would like to access the previous hour (template instance) to add it to the current hour.

I have a template parameter for the parts completed that hour. My project crashes as soon as I try to access that parameter, or any other parameter, from another template instance.

Thank you.

Hi rdeavers,

How are you accessing the template parameter? Scripting? Property binding? Expression binding?

What version of Ignition are you using?

If you can create a simple version of the template with the problem and then export it and upload it to this forum topic then I will check it out and if there is a bug then the template can be sent to IA and the bug can be fixed.

Nick Mudge
Ignition Consultant


I’m accessing the template from a property change script My Ignition version is 7.6.4
Creating a simple one will take some time but I’ll work on it and post it.

Okay, you could post your propertyChange script here. That might be enough to determine the problem.

Here is a simple version of my script:

if event.source.instanceName: if event.source.instanceName == 'testTemplate1': event.source.thisValue = '1' elif event.source.instanceName == 'testTemplate2': event.source.thisValue = event.source.parent.getComponent('testTemplate1').thisValue + '1' elif event.source.instanceName == 'testTemplate3': event.source.thisValue = event.source.parent.getComponent('testTemplate2').thisValue + '1'

My error is this:
Traceback (most recent call last):
File “event:propertyChange”, line 7, in
TypeError: getComponent(): 1st arg can’t be coerced to int

Is this propertyChange script on the parent template, not on one of the templates within the template?

Because if so the referencing event.source.parent.getComponent doesn’t work.

In addition your counting custom variable should be an Integer instead of a String.

Try this script:

#Only run this script if the instanceName property changes
if event.propertyName == "instanceName":
   if event.source.instanceName == 'testTemplate1':
      event.source.thisValue = 1
   elif event.source.instanceName == 'testTemplate2':
      event.source.thisValue = event.source.getComponent('testTemplate1').thisValue + 1
   elif event.source.instanceName == 'testTemplate3':
      event.source.thisValue = event.source.getComponent('testTemplate2').thisValue + 1

Nick Mudge
Ignition Consultant

I still receive the same error. Here is an example of my form with multiple instances of the template inside. I have a button from another form calling testWindow.

Hi rdeavers,

I imported the template and window into Ignition. There is no scripts on them. How do I reproduce the issue?

Nick Mudge
Ignition Consultant

My issue was accessing a template on a form from another template on the same form. To do this, I was using:


However, I learned from tech support that templates are in another container so the correct way to do what I needed is add another parent level.:


My program now works correctly. I do appreciate the help.