# Opening a window on table row selection and passing a parameter to the opening window

**URL:** <https://forum.inductiveautomation.com/t/opening-a-window-on-table-row-selection-and-passing-a-parameter-to-the-opening-window/84951>\
**Category:** Ignition\
**Tags:** vision\
**Created:** [January 30, 2024, 2:19pm UTC](https://forum.inductiveautomation.com/t/opening-a-window-on-table-row-selection-and-passing-a-parameter-to-the-opening-window/84951 "2024-01-30T14:19:05Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![jshaffer09](https://avatars.discourse-cdn.com/v4/letter/j/df788c/32.png) [@jshaffer09](https://forum.inductiveautomation.com/u/jshaffer09)\
**Post date:** [January 30, 2024, 2:19pm UTC](https://forum.inductiveautomation.com/t/opening-a-window-on-table-row-selection-and-passing-a-parameter-to-the-opening-window/84951/1 "2024-01-30T14:19:05Z")

</div>

In vision, I am trying to open a window with a table row selection and pass a parameter from the row selection to the opening window. I am able to open the window but it doesn't pass the parameter to the tables custom property 'Date'. I have the same custom property 'Date' on the window where I am selecting the row from the table. Any ideas?

```auto
table = event.source 
if table.selectedRow>=0: 
    param = table.data.getValueAt(table.selectedRow, "DateOnly") 
    system.nav.openWindow("Maintenance/Burner Off/Dryer 1 Burner Day History 
    {"Date": param})

```

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [January 30, 2024, 2:43pm UTC](https://forum.inductiveautomation.com/t/opening-a-window-on-table-row-selection-and-passing-a-parameter-to-the-opening-window/84951/2 "2024-01-30T14:43:27Z")

</div>

This is a propertyChange event on the table? Perhaps try rewriting it like this:

```auto
if event.propertyName == 'selectedRow' and event.NewValue > -1: 
    param = table.data.getValueAt(event.newValue, "DateOnly") 
    system.nav.openWindow("Maintenance/Burner Off/Dryer 1 Burner Day History", {"Date": param})

```

_Note how this can only happen on one propertyChange event, and that a missing quotation mark on your window path as well as a comma seperating the path and the parameters have been added._

**Edit:** Removed an inadvertent enter after the widow path

---

<div class="post-metadata">

**Author:** ![jshaffer09](https://avatars.discourse-cdn.com/v4/letter/j/df788c/32.png) [@jshaffer09](https://forum.inductiveautomation.com/u/jshaffer09)\
**Post date:** [January 30, 2024, 2:47pm UTC](https://forum.inductiveautomation.com/t/opening-a-window-on-table-row-selection-and-passing-a-parameter-to-the-opening-window/84951/3 "2024-01-30T14:47:40Z")

</div>

I got it to work, I had to put the custom property on the window and not the new table. I added some print statements, then realized my error.

```auto
table = event.source

if table.selectedRow >= 0:
    param = table.data.getValueAt(table.selectedRow, "DateOnly")
    
    # Print statements for debugging
    print("Selected DateOnly:", param)
    
    windowPath = "Maintenance/Burner Off/Dryer 1 Burner Day History"
    parameters = {"Date": param}
    
    # Print statements for debugging
    print("Opening window with parameters:", parameters)
    
    system.nav.openWindow(windowPath, parameters)

```

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [January 30, 2024, 2:51pm UTC](https://forum.inductiveautomation.com/t/opening-a-window-on-table-row-selection-and-passing-a-parameter-to-the-opening-window/84951/4 "2024-01-30T14:51:58Z")

</div>

I'm glad you got it to work, but please consider the script I offered. The best practice is to limit propertyChange event scripts to specific properties. The initial `if` statement for any propertyChange event should include the property name, and all scripting logic for that event should occur within that `if` statement. Otherwise that code will evaluate for every property that changes on the component.

---

<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 30, 2024, 3:03pm UTC](https://forum.inductiveautomation.com/t/opening-a-window-on-table-row-selection-and-passing-a-parameter-to-the-opening-window/84951/5 "2024-01-30T15:03:50Z")

</div>

> [@justinedwards.jle](#):
>
> The best practice is to limit propertyChange event scripts to specific properties.

Not just a "best practice". You will have numerous weird bugs if you fail to check `event.propertyName` for the property you need to monitor.

---

<div class="post-metadata">

**Author:** ![jshaffer09](https://avatars.discourse-cdn.com/v4/letter/j/df788c/32.png) [@jshaffer09](https://forum.inductiveautomation.com/u/jshaffer09)\
**Post date:** [January 30, 2024, 3:10pm UTC](https://forum.inductiveautomation.com/t/opening-a-window-on-table-row-selection-and-passing-a-parameter-to-the-opening-window/84951/6 "2024-01-30T15:10:08Z")

</div>

> [@justinedwards.jle](#):
>
> ```auto
> if event.propertyName == 'selectedRow' and event.NewValue > -1: 
> param = table.data.getValueAt(event.newValue, "DateOnly") 
> system.nav.openWindow("Maintenance/Burner Off/Dryer 1 Burner Day History", {"Date": param})
> 
> ```

when I try your example I get a error

```auto
Traceback (most recent call last):
  File "<event:mouseClicked>", line 1, in <module>
AttributeError: 'java.awt.event.MouseEvent' object has no attribute 'propertyName'

```

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [January 30, 2024, 3:15pm UTC](https://forum.inductiveautomation.com/t/opening-a-window-on-table-row-selection-and-passing-a-parameter-to-the-opening-window/84951/7 "2024-01-30T15:15:07Z")

</div>

I see; you are using the mouse clicked event. I use the propertyChange event for this sort of thing, so I had imagined that's what you were using.

---

<div class="post-metadata">

**Author:** ![jshaffer09](https://avatars.discourse-cdn.com/v4/letter/j/df788c/32.png) [@jshaffer09](https://forum.inductiveautomation.com/u/jshaffer09)\
**Post date:** [January 30, 2024, 4:22pm UTC](https://forum.inductiveautomation.com/t/opening-a-window-on-table-row-selection-and-passing-a-parameter-to-the-opening-window/84951/8 "2024-01-30T16:22:38Z")

</div>

got it, changed it to property change script. Thanks for the help.
