# Window path template property

**URL:** <https://forum.inductiveautomation.com/t/window-path-template-property/31577>\
**Category:** Ignition\
**Created:** [January 23, 2020, 11:58pm UTC](https://forum.inductiveautomation.com/t/window-path-template-property/31577 "2020-01-23T23:58:58Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![john.eichler](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/john.eichler/32/24632_2.png) [@john.eichler](https://forum.inductiveautomation.com/u/john.eichler)\
**Post date:** [January 23, 2020, 11:58pm UTC](https://forum.inductiveautomation.com/t/window-path-template-property/31577/1 "2020-01-23T23:58:58Z")

</div>

Hi All  
Using the following post, I have made a simple button which updates a historical chart with the latest data on the click of a button.

> [@EasyChart Historical mode does not update with new data](http://forum.inductiveautomation.com/t/easychart-historical-mode-does-not-update-with-new-data/23677):
>
> I’ve noticed that the EasyChart using the Historical mode does not automatically pull in new trend data once the daterange has been set. If this range is set to a range that includes ‘now’ and beyond, new data is not pulled in until you modify the daterange slightly. Is this intentional by design, or perhaps a bug? Regardless, how can I force this to refresh its data every x seconds? I have tried to use a Timer component, but I’m not sure what property or method I can use to manually force the…

I've made this into a template since I plan to use it in multiple places through a project. I currently pass two custom property strings into the template, ChartName and WindowPath. The following script is fired by "actionPerformed" on the button within the template.

```auto
> # Load the chart name
> ChartName = event.source.parent.ChartName
> 
> # Get a reference to the window containing the chart
> window = system.gui.getWindow(event.source.parent.WindowPath)
> 
> # Build a reference to the chart
> chart = window.rootContainer.getComponent(ChartName) 
> 
> # Set the chart end date to the current date
> chart.endDate = system.date.now()

```

This works perfectly but is there a nicer way to get a reference to the window containing the template that was clicked? I've looked at the system.gui functions. Ideally, I'd like to not have the window path as a property since I will always be updating the chart on the same window as the button (template). Note, there may be pop up windows open at the time the user clicks the button in question.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/2X/2/2a5503a2244ff6fab979887719f1ffc93686638e.png)

Cheers

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [January 24, 2020, 1:16am UTC](https://forum.inductiveautomation.com/t/window-path-template-property/31577/2 "2020-01-24T01:16:20Z")

</div>

Should just be able to use `system.gui.getParentWindow`

---

<div class="post-metadata">

**Author:** ![john.eichler](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/john.eichler/32/24632_2.png) [@john.eichler](https://forum.inductiveautomation.com/u/john.eichler)\
**Post date:** [January 24, 2020, 1:28am UTC](https://forum.inductiveautomation.com/t/window-path-template-property/31577/3 "2020-01-24T01:28:17Z")

</div>

Thanks for the reply. I tried that but I think it returns the root container for the template, not the window.

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [January 24, 2020, 2:14am UTC](https://forum.inductiveautomation.com/t/window-path-template-property/31577/4 "2020-01-24T02:14:04Z")

</div>

Are you sure? I just tried it now and am getting the window itself. Version 7.9.12

---

<div class="post-metadata">

**Author:** ![john.eichler](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/john.eichler/32/24632_2.png) [@john.eichler](https://forum.inductiveautomation.com/u/john.eichler)\
**Post date:** [January 24, 2020, 2:27am UTC](https://forum.inductiveautomation.com/t/window-path-template-property/31577/5 "2020-01-24T02:27:28Z")

</div>

I get an error stating that root container does not exist in the window (I think).

Any ideas? Thanks for your help.

![image](https://us1.discourse-cdn.com/inductiveautomation/original/2X/f/ffb3641fa3357ee6f607e22591dbc25deb2db47b.png)

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/2X/3/3a5ab045283f9767da88a50aa57f10aa42480736.png)

---

<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:** [January 24, 2020, 3:26am UTC](https://forum.inductiveautomation.com/t/window-path-template-property/31577/6 "2020-01-24T03:26:36Z")

</div>

You aren’t passing anything to getParentWindow, no parentheses even, so the variable `window` holds a reference to the function, un-executed, not the return value from the function. A function object would not have the properties of a window.

---

<div class="post-metadata">

**Author:** ![john.eichler](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/john.eichler/32/24632_2.png) [@john.eichler](https://forum.inductiveautomation.com/u/john.eichler)\
**Post date:** [January 24, 2020, 4:17am UTC](https://forum.inductiveautomation.com/t/window-path-template-property/31577/7 "2020-01-24T04:17:31Z")

</div>

Got it. Thanks for the pointer. This code now works and I am able to pass only the chart name to the template.

```auto
# Load the chart name
ChartName = event.source.parent.ChartName

# Get a reference to the window containing the chart
window = system.gui.getParentWindow(event)

# Build a reference to the chart
chart = window.rootContainer.getComponent(ChartName)

# Set the chart end date to the current date
chart.endDate = system.date.now()

```
