Object has no attribute 'getLoadedTemplates'

I'm encountering an issue when trying to access a component value within a Template Repeater in Ignition. To debug this, I have created a simple test screen based on the example code provided in the user manual. My goal is to display the text of a Label component inside the Template Repeater as a message when the button is clicked. However, I keep encountering errors when attempting to do this. Here's a screenshot of my test screen and the code I am using. Please note that I have ensured the component names match those in the example code. Can anyone provide assistance or guidance on how to resolve this issue?

#This script will call getLoadedTemplates() on a Template Repeater, and
#then print the text property of a Label component in each instance
 
#Store a reference to the Template Repeater component in a variable
repeater = event.source.parent.getComponent('Template Repeater')
 
#Store the list of templates in another variable
templateList = repeater.getLoadedTemplates()
 
#Iterate through the list
for template in templateList:
    #find a component named "Label" in the instance,
    #and print the value of the text property 
    print template.getComponent('Label').text

error:

Traceback (most recent call last):
  File "<event:actionPerformed>", line 8, in <module>
AttributeError: 'com.inductiveautomation.factorypmi.application.com' object has no attribute 'getLoadedTemplates'


Ignition v8.1.21 (b2022092908)
Java: Azul Systems, Inc. 11.0.15

I also tried to change the getLoadedTemplates to getTemplateInstances , it does not work.

Vision - Template Repeater - Ignition User Manual 8.1 - Ignition Documentation (inductiveautomation.com)

The object you are displaying is named Template Repeater, but your icon is actually that of a template itself, not an actual template repeater. Are you using a template with a template repeater inside of it? If so, you will need to modify your script, so it gets the template repeater from inside the template itself .

Example:

from com.inductiveautomation.factorypmi.application.components import TemplateRepeater
visionTemplate = event.source.parent.getComponent('Template Repeater').getComponent(0)
for component in visionTemplate.getComponents():
	if isinstance(component, TemplateRepeater):
		#template repeater code here
		break

Template Icon:
image

Template Repeater Icon:
image

1 Like