Getting A Value From A Template In A Template Repeater

How do I get a value from a specific numeric text field component that’s inside of a template repeater? I’d like to take that value and store it in a database through scripting.

1 Like

templates = event.source.parent.getComponent('Template Repeater').getLoadedTemplates() for template in templates: print "Value: ", template.getPropertyValue("TextValue")

Where TextValue is a template parameter or internal property of the template.

I tried this out and got the following error

[quote]AttributeError: ‘com.inductiveautomation.factorypmi.application.com’ object has no attribute ‘getLoadedTemplates’
[/quote]
I even tried getTemplates() and got the same error. Also looking at the documentation, under Scripting Functions, it says This component has no special scripting functions. How are we able to get data from the repeater?
I am using Ignition 7.7.1

Hi rdeavers,

I tried this:

templateRepeater = event.source.parent.getComponent('Template Repeater') print templateRepeater templates = templateRepeater.getLoadedTemplates() for template in templates: print "Value: ", template.getPropertyValue("tankLevel")

And I got this:

com.inductiveautomation.factorypmi.application.components.TemplateRepeater[Template Repeater,96,45,587x544,layout=com.inductiveautomation.ignition.client.util.gui.FillingLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=9,maximumSize=,minimumSize=,preferredSize=] Value: 27 Value: 27 Value: 27 Value: 27

Perhaps, you can also print what component you get to ensure that it is really a template repeater

templateRepeater = event.source.parent.getComponent('Template Repeater') print templateRepeater

The attribute error:

AttributeError: 'com.inductiveautomation.factorypmi.application.com' object has no attribute 'getLoadedTemplates'

could be caused because the object isn’t really a template repeater.

I use Ignition 7.7.4

My apologize,

these two should be quotes instead of code

[quote]com.inductiveautomation.factorypmi.application.components.TemplateRepeater[Template Repeater,96,45,587x544,layout=com.inductiveautomation.ignition.client.util.gui.FillingLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=9,maximumSize=,minimumSize=,preferredSize=]
Value: 27
Value: 27
Value: 27
Value: 27[/quote]

Sorry for the confusion…

Hi rayjones9210,

If what you meant is to get a property value of a component in a template within a template repeater, then you can further get the component from the template after you obtain your template from a template receiver.

Something like this:

templateRepeater = event.source.parent.getComponent('Template Repeater') #get the template repeater templates = templateRepeater.getLoadedTemplates() #get all templates in template repeater template = templates[0] #note that [0] refers to the first template in the templateRepeater label = template.getComponent('Label') #get the component in the template print label.text #get a property value of a component

It worked after I upgraded to 7.7.5. This function does not work in 7.7.1.

Thanks for your help.

Hi rdeavers,

Glad to hear that! So, it is really the version, not the component type… :slight_smile: