UDTable within UDStepper

Product: PowerShell Universal
Version: 2.5.4


I’m trying to retrieve selected rows of an UDTable inside an UDStepper with no luck.
Maybe it’s because UDTable is not supported by UDstepper since it’s not mentioned in the UDStepper doc

I need to make a multiple selection in the first step, so, what’s my best option ?


UDTable won’t propagate selections to a UDStepper. You can use the -OnRowSelected event handler to capture when items are selected and then store that result in a $Session variable. In -OnSubmit, you could then use that value in combination with the $EventData variable.

Thanks Adam for your quick reply. I will try that.

I’ve tried to add :
$Session:ShowSelectedItem = $EventData in the -OnRowSelection

But at the next step when I tried to loop over selected items ($Session:ShowSelectedItem)
foreach($device in $Session:ShowSelectedItem){
New-UDTable -data $device
It create only one UDTable with the las slected item

Edit :

Used a List object with -OnRowSelection :
$Session:SelectedRowList = New-Object Collections.Generic.List[PSCustomObject]
$Session:ShowSelectedItem = $EventData
Then used a foreach
foreach($row in $session:SelectedRowList){

                Show-UDToast -Message $row -Duration 30000


But how can I handle the event of unselection ? :thinking:

What I did in this situation was use a hashtable (Session var), and then I would make sure to use data from the table that is unique as my key, with the rest as data (this can be another hashtable for example). so you can use the -OnRowSelection block to check when clicked if the key is already in the hashtable if so → remove otherwise → add.

here an example, hope it helps :wink:

-OnRowSelection {
    $row = $EventData
    if (selection.Keys -notcontains $row.Id) {
        $selection.Add($row.Id, $row)
    else {