# Browse windows, templates with script?

**URL:** <https://forum.inductiveautomation.com/t/browse-windows-templates-with-script/67797>\
**Category:** Ignition\
**Tags:** ignition81, vision, scripting\
**Created:** [December 19, 2022, 5:33pm UTC](https://forum.inductiveautomation.com/t/browse-windows-templates-with-script/67797 "2022-12-19T17:33:50Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Esn](https://avatars.discourse-cdn.com/v4/letter/e/91b2a8/32.png) [@Esn](https://forum.inductiveautomation.com/u/Esn)\
**Post date:** [December 19, 2022, 5:33pm UTC](https://forum.inductiveautomation.com/t/browse-windows-templates-with-script/67797/1 "2022-12-19T17:33:50Z")

</div>

Hi,

I it possible to browse and change windows as with the following pseudo code?

```auto
for window in allWindows:
    for component in window.components:
        component.setProperty('propertyName', propertyValue)

```

and maybe something similar for templates?

Thanks

---

<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:** [December 19, 2022, 6:08pm UTC](https://forum.inductiveautomation.com/t/browse-windows-templates-with-script/67797/2 "2022-12-19T18:08:52Z")

</div>

Sort of. Windows are stored in a binary serialized form, so they have to be _open_ to manipulate them. A script can open a window, manipulate it, and close it again. If in the designer, and the project is then saved, the property change will be present for later Vision clients.

I don't think there's anything like that for templates.

In a Vision client, you can do similar, but changes will not persist until the next open.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [December 19, 2022, 6:14pm UTC](https://forum.inductiveautomation.com/t/browse-windows-templates-with-script/67797/3 "2022-12-19T18:14:11Z")

</div>

Find & Replace is the supported way to do this:  
[https://docs.inductiveautomation.com/display/DOC81/Find+and+Replace](https://docs.inductiveautomation.com/display/DOC81/Find+and+Replace)

---

<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:** [December 20, 2022, 1:26am UTC](https://forum.inductiveautomation.com/t/browse-windows-templates-with-script/67797/4 "2022-12-20T01:26:29Z")

</div>

Paul's suggestion is the simplest solution for most scenarios. As the documentation shows, simply select the "All Windows" option and perform the search:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/4/04b4e1632a44393a8c9780ebd6e7561b0043c891.png)

However, if it's something complicated that requires scripting, the following code will do the work for you:

```auto
for name in system.gui.getWindowNames():
	system.nav.openWindow(name)
	components = system.gui.getWindow(name).getRootContainer().getComponents()
	for component in components:
		#identify your component, and do the necessary work here
	system.nav.closeWindow(name)

```

Here is a more advanced example that effectively illustrates such a scenario:

> [@Ignition 8.1 PowerTable header background color](https://forum.inductiveautomation.com/t/ignition-8-1-powertable-header-background-color/64854/15):
>
> Using @PGriffith's direction, I have developed a script that will accomplish the goal of globally changing all power table header configurations from the designer. The script opens every vision window, then loops through getting all of the components from each window's root container. Then it checks each component list for power tables and nested containers. If there is a nested container, it repeats the process until there are no more nested containers.\* \*For each power table found, if the con…

---

<div class="post-metadata">

**Author:** ![Esn](https://avatars.discourse-cdn.com/v4/letter/e/91b2a8/32.png) [@Esn](https://forum.inductiveautomation.com/u/Esn)\
**Post date:** [December 20, 2022, 8:09am UTC](https://forum.inductiveautomation.com/t/browse-windows-templates-with-script/67797/5 "2022-12-20T08:09:34Z")

</div>

The actual task at hand is this:

We have a few base templates which represents pumps, valves, etc.

These templates have been instantiated maybe over 1000 times each and are spread over a large number of windows and other templates.

We now have to assign the base templates a new custom parameter and afterwards it needs to be assigned data on each instance.  
The data on each template instance varies so I don't see how i can use search and replace.

What is the best way to go about this?

@justinedwards.jle thanks, that looks promising for our windows 🙂

---

<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:** [December 20, 2022, 2:11pm UTC](https://forum.inductiveautomation.com/t/browse-windows-templates-with-script/67797/6 "2022-12-20T14:11:43Z")

</div>

> [@Esn](#):
>
> We now have to assign the base templates a new custom parameter and afterwards it needs to be assigned data on each instance.

I'm having a hard time visualizing this. Why can't the custom parameter be the same on each template? What is the data dependent on that makes it different? Is it a window property that you can bind to? Can you put a script in the template that sets the parameter automatically based off of the window it's in?

I love using templates because they automatically inherit changes. They make updates and maintenance quick and easy, but they have to be designed in a way that is universal for there purpose. If an individual modification is required for some scenarios, it's probably better from a maintenance standpoint to simply have more than one template.
