# Dynamic Scripting

**URL:** <https://forum.inductiveautomation.com/t/dynamic-scripting/17266>\
**Category:** Ignition\
**Created:** [March 7, 2018, 6:17pm UTC](https://forum.inductiveautomation.com/t/dynamic-scripting/17266 "2018-03-07T18:17:28Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mr.K001](https://avatars.discourse-cdn.com/v4/letter/m/ea5d25/32.png) [@Mr.K001](https://forum.inductiveautomation.com/u/Mr.K001)\
**Post date:** [March 7, 2018, 6:17pm UTC](https://forum.inductiveautomation.com/t/dynamic-scripting/17266/1 "2018-03-07T18:17:28Z")

</div>

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!!!

---

<div class="post-metadata">

**Author:** ![Mr.K001](https://avatars.discourse-cdn.com/v4/letter/m/ea5d25/32.png) [@Mr.K001](https://forum.inductiveautomation.com/u/Mr.K001)\
**Post date:** [March 7, 2018, 6:26pm UTC](https://forum.inductiveautomation.com/t/dynamic-scripting/17266/2 "2018-03-07T18:26:18Z")

</div>

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

```auto
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 👍

---

<div class="post-metadata">

**Author:** ![phillip.bow](https://avatars.discourse-cdn.com/v4/letter/p/ce73a5/32.png) [@phillip.bow](https://forum.inductiveautomation.com/u/phillip.bow)\
**Post date:** [March 7, 2018, 7:04pm UTC](https://forum.inductiveautomation.com/t/dynamic-scripting/17266/3 "2018-03-07T19:04:15Z")

</div>

Have you tried:

```auto
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:

```auto
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.

---

<div class="post-metadata">

**Author:** ![Mr.K001](https://avatars.discourse-cdn.com/v4/letter/m/ea5d25/32.png) [@Mr.K001](https://forum.inductiveautomation.com/u/Mr.K001)\
**Post date:** [March 7, 2018, 7:47pm UTC](https://forum.inductiveautomation.com/t/dynamic-scripting/17266/4 "2018-03-07T19:47:13Z")

</div>

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

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

```

.getPropertyValue did the trick!  
Learn something new everyday 😁👍

---

<div class="post-metadata">

**Author:** ![laurie.croteau](https://avatars.discourse-cdn.com/v4/letter/l/73ab20/32.png) [@laurie.croteau](https://forum.inductiveautomation.com/u/laurie.croteau)\
**Post date:** [November 1, 2021, 2:49pm UTC](https://forum.inductiveautomation.com/t/dynamic-scripting/17266/5 "2021-11-01T14:49:51Z")

</div>

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:

```auto
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?

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [November 1, 2021, 2:55pm UTC](https://forum.inductiveautomation.com/t/dynamic-scripting/17266/6 "2021-11-01T14:55:25Z")

</div>

`NumericEntryField.props.value`

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.

---

<div class="post-metadata">

**Author:** ![ryan.white](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.white/32/73193_2.png) [@ryan.white](https://forum.inductiveautomation.com/u/ryan.white)\
**Post date:** [November 3, 2021, 9:30pm UTC](https://forum.inductiveautomation.com/t/dynamic-scripting/17266/7 "2021-11-03T21:30:15Z")

</div>

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.
