Dynamic Scripting

Hi everyone,
So I have this popup I have that is meant to grab data from a selected row of a window so user can make changes to the data and update it.
I have some datasets components on the main page on the RootContainer for fault reasons, basically depending on what department the user selects those the fault dropdown will change to the appropriate dataset.
Now I want to have that option in the popup window and I was thinking instead of bringing all of those datasets to the popup window lets try to have one dataset component and grab the data i want dynamically from the main window based on what department the user selects.
Here is the question, for the following script:
system.gui.getWindow(sourceWindowPath).getRootContainer().someDataSet
How can I make the “someDataSet” dynamic, the fault datasets are the same names as the department names being selected so if I can just change the last part of that script dynamically I’m set. Something like:
system.gui.getWindow(sourceWindowPath).getRootContainer().variable
I tried a few things and none worked, I figured I put it on here and see what happens.
If there is no easy way I’ll just pass the datasets when I open the window, I just thought it be cool to learn a new trick.

Thanks!!!

Update:
figured the window part out, i was doing it wrong I have this so far:

sourceWindowPath = 'path'
dept = event.source.selectedLabel

if event.propertyName == 'selectedValue':
	if event.newValue >= 0: 
		data = system.gui.getWindow(sourceWindowPath).rootContainer.getComponent(dept)
		event.source.parent.parent.parent.issues = data

I just have to figure out the last part to add the dataset to the new one on the popup RootContainer :+1:

Have you tried:

currentDataSet = event.source.selectedLabel
system.gui.getWindow(sourceWindowPath).getRootContainer().getPropertyValue(currentDataSet)

I set up a MainWindow with a listbox containing dept names and a propertyChange script like:

if event.propertyName == "selectedIndex":
	val = event.source.data.getValueAt(event.newValue, 0)
	dataSet = event.source.parent.getPropertyValue(val)
	
	system.nav.openWindow("Subscriber", {'CurrentDataSet' : dataSet})

Then a pop up window with a CurrentDataSet custom property, and table bound to it and I think I’m getting the behavior you’re after.

1 Like

Thanks!!! didn’t really have to change anything, just used the following to grab my data from the main window instead of rootContainer.getComponent

system.gui.getWindow(sourceWindowPath).getRootContainer().getPropertyValue(currentDataSet)

.getPropertyValue did the trick!
Learn something new everyday :grin::+1: