# Template Canvas customizer through scripting

**URL:** <https://forum.inductiveautomation.com/t/template-canvas-customizer-through-scripting/82301>\
**Category:** Ignition\
**Tags:** vision\
**Created:** [November 23, 2023, 2:35pm UTC](https://forum.inductiveautomation.com/t/template-canvas-customizer-through-scripting/82301 "2023-11-23T14:35:36Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rodrigo\_Domingues](https://avatars.discourse-cdn.com/v4/letter/r/cdc98d/32.png) [@Rodrigo\_Domingues](https://forum.inductiveautomation.com/u/Rodrigo_Domingues)\
**Post date:** [November 23, 2023, 2:35pm UTC](https://forum.inductiveautomation.com/t/template-canvas-customizer-through-scripting/82301/1 "2023-11-23T14:35:36Z")

</div>

Hi there,

I have a Template canvas object in my window and instead of using the template canvas customizer to add instances of my template, setting its name, position, width, height, parameter (...) . I want to edit those fields through script. Is it possible?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [November 23, 2023, 4:34pm UTC](https://forum.inductiveautomation.com/t/template-canvas-customizer-through-scripting/82301/2 "2023-11-23T16:34:17Z")

</div>

Yes, the property that drives the entire template canvas is just a dataset, and is well-documented. Simply write a script that generates the dataset dynamically with the necessary content.

---

<div class="post-metadata">

**Author:** ![Irfan\_Shaik](https://avatars.discourse-cdn.com/v4/letter/i/53a042/32.png) [@Irfan\_Shaik](https://forum.inductiveautomation.com/u/Irfan_Shaik)\
**Post date:** [March 15, 2024, 5:24pm UTC](https://forum.inductiveautomation.com/t/template-canvas-customizer-through-scripting/82301/3 "2024-03-15T17:24:09Z")

</div>

For a dropdown template how do we pass the dataset in to canvas dataset?

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [March 16, 2024, 9:08am UTC](https://forum.inductiveautomation.com/t/template-canvas-customizer-through-scripting/82301/4 "2024-03-16T09:08:58Z")

</div>

> [@Irfan\_Shaik](#):
>
> For a dropdown template

I assume this means the dropdown is being rendered by the canvas. If that is the case, you will have to navigate the parent hierarchy to manipulate the dataset. Here is an example of how to do this using the dropdown's `propertyChange` event handler:

```auto
# Written for a dropdown component's propertyChange event handler
# Only execute the dataset manipulation if it is the selected index property that has changed
if event.propertyName == 'selectedIndex' and event.newValue > -1:
	# Import swing utilites and a the template canvas class to retrieve the parent canvas without a recursive function
	from javax.swing import SwingUtilities
	from com.inductiveautomation.factorypmi.application.components import TemplateCanvas
	
	# Get the canvas from the parent hierarchy using swing utilities
	canvas = SwingUtilities.getAncestorOfClass(TemplateCanvas, event.source)
	
	# Check to see if template is being rendered by a canvas
	if canvas is not None:	
		# Get the templates dataset from the canvas
		dataset = canvas.templates
		
		# ***********************
		# newDataset = manipulate dataset in some way here
		# ***********************
		
		# Write manipulated dataset back to the canvas's templates property
		canvas.templates = newDataset

```
