Help to call custom method on template repeater from 2 state toggle on a template

Objective is to update selected index on another standard template based on selected 2 state toggle in template repeater.

I need to call a custom method on a template repeater from a 2-state toggle used on the template inside the repeater.

Template repeater method:

def checkReason(self):

	templates = event.source.getLoadedTemplates()
	for template in templates:
		if template.getComponent('poiStatus').IsSelected == 1:
			poi_desc = str(template.poi_desc)
			passList = ["BURN MARK","FLASH","GLASS FIBERS","GATE VESTIGE","SHORT SHOT"]
			if poi_desc in passList:
				#SET TO DAMAGED REASON INDEX
				event.source.parent.getComponent('Reason').selReason = 4

template repeater>template>2-state toggle action performed event handler call to checkReason():

event.source.parent.parent.checkReason()

I have tried with up to 4 parents nested in this call. Still getting error that object has to attribute checkReason. Maybe I’m not understanding the parent part.

Try using

print event.source.parent.parent.parent.name

You probably just need another parent, or 1 fewer.
Printing the type can also help as well e. G. type(event.sourxe......)

Everything past just one parent is coming back as None from the print statement. Just one parent shows the name of the template. Two parents has none instead of the name of the template repeater.

What about the type?

There are additional 3 layers between the template and the template repeater.

Below is debug print result for an example of: Template Repeater > Template > Button. If I need to call customer method on the template repeater from the button within the template. I need use 5 '.parent'.

# Below is just debug print to check how to call a custom method on a template repeater from a component within a template
# You can see that there are additional 3 layers between template repeator and template

print 'name is', event.source.name, 
print 'type is', type(event.source)

print 'name is', event.source.parent.name, 
print 'type is', type(event.source.parent)

print 'name is', event.source.parent.parent.name, 
print 'type is', type(event.source.parent.parent)

print 'name is', event.source.parent.parent.parent.name, 
print 'type is', type(event.source.parent.parent.parent)

print 'name is', event.source.parent.parent.parent.parent.name, 
print 'type is', type(event.source.parent.parent.parent.parent)

print 'name is', event.source.parent.parent.parent.parent.parent.name, 
print 'type is', type(event.source.parent.parent.parent.parent.parent)

below is output on console:

name is Button 
type is <type 'com.inductiveautomation.factorypmi.application.components.PMIButton'>

name is Template
type is <type 'com.inductiveautomation.factorypmi.application.components.template.VisionTemplate'>

name is None 
type is <type 'com.inductiveautomation.factorypmi.application.components.TemplateRepeater$VerticalView'>

name is None 
type is <type 'javax.swing.JViewport'>

name is None 
type is <type 'com.jidesoft.swing.JideScrollPane'>

name is Template Repeater 
type is <type 'com.inductiveautomation.factorypmi.application.components.TemplateRepeater'>