Using script to create a template instance?

Hi there,
Is there a script command to create a template instance?

I’m dealing with a project to create input boxes based on the result I query from other system.
For example, there are 4 items returned from the query and each item has different number of inputs required. Something like

item1 requires 2 input boxes
item2 requires 1 input boxes
item3 requires 10 input boxes
item4 requires 5 input boxes

My idea is to create a template with dropdown list and text input components. Each template is for each item and dropdown list will be a number of inputs required. User will be select number and enter value in the text input components then store as a dataset or dictionary type.

I want to be able to create template instance from script based on the number of items returned.

If there are any other better ways to do, please suggest.

The recommended approach is to use the Template Canvas or Template Repeater to dynamically create template instances. Here’s a tutorial on the Template Canvas: nickmudge.info/post/ignitions-te … at-runtime

Best,

Thank you Nick, stuff in your link is very helpful.

I would like to recreate the Template Canvas Customizer in a client window to give users the ability to build dashboards on their own without the designer.

I think I can do just about everything to populate the Templates dataset except for providing the drop-down of available templates and then expose the selected template’s parameters. I know I could build database tables pre-populated with template names and parameters but was hoping to just use whatever the customizer is using.

Thanks in advance -

I’m looking for this drop down as well (Here). I had a quick look in the SDK documentation without success so far…

You’d need to do something in addition to this for the UDT association but this will list templates from the designer. I think I got it from Nick originally but don’t see that post anymore. This is on the mousePressed event of a drop-down:

[code]def getProjectTemplates(event):
import system
comp = event.source
if system.util.getSystemFlags() & system.util.DESIGNER_FLAG:
from com.inductiveautomation.ignition.designer import IgnitionDesigner
while not isinstance(comp,IgnitionDesigner):
comp = comp.parent
context = comp.getContext()
else:
from com.inductiveautomation.factorypmi.application.runtime import ClientPanel
while not isinstance(comp,ClientPanel):
comp = comp.parent
context = comp.getClientContext()
project = context.getProject()
templates = project.getResourcesOfType(“fpmi”,“component-template”)
templatePaths = [project.getFolderPath(template.getResourceId()) for template in templates]
return templatePaths

#Get templates from Gateway
l = []
templatePaths = getProjectTemplates(event)
for path in templatePaths:
if path.startswith(“Dashboard/”):
#Use specific folder to hold all Dashboard-related templates
l.append([path])

data = system.dataset.toDataSet([“Value”], l)
event.source.data = data[/code]

Thank you for the reply. It helped a lot.

I’ll keep looking for the UDT association and will post here if I find something interesting.