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.
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.
> # 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.