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


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

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


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

I’m trying to used a OnChanged script and I used system.gui.getWindow(sourceWindowPath).getRootContainer().getPropertyValue(Nom) to get some data from my view. Nom is a label in my current view. However, I’m getting this error:

Error running property change script on NumericEntryField.props.value: Traceback (most recent call last):
File "<function:valueChanged>", line 3, in valueChanged
AttributeError: 'com.inductiveautomation.ignition.common.script.Imm' object has no attribute 'gui'

Can you help me?


Looks like you are calling system.gui in Perspective. system.gui only works with Vision. You will need to try to get the view in a different manner, I cannot help you there, been a while since I touched perspective, but I can tell you that system.gui will not work.

1 Like

In perspective I believe you’ll have to pass the data as a parameter when you call the popup. You’ll also have to have a message listener on the item that called the popup to handle the modified data that is returned.