Obtain the value of a UDSelect in a table column

Could someone point me in the right direction to get the value of “UDSelect” from within a table column? I felt like this was close to what I was trying to do. How can I use -OnRowSelection to get value from text box inside a table - PowerShell Universal / Universal Dashboard - Ironman Software Forums I still can’t connect the dots on what is missing.

I can obtain the first column “project” data I need using Get-UDElement and “selected rows”, but when I try to use the same method for the column “permission” with UDSelect, I can’t seem to figure out how to get my data to show up.

$Project = 'Project1','Project2','Project3'

$Column = @(
    New-UDTableColumn -Property project -Title Projects -FilterType text
    New-UDTableColumn -Property permission -Title Permissions -Render {
        New-UDSelect -Option {
            New-UDSelectOption -Name 'Member' -Value 'Member'
            New-UDSelectOption -Name 'Administrator' -Value 'Administrator'
            New-UDSelectOption -Name 'Contractor' -Value 'Contractor'
        } -Id 'UDProjectSelect'
    }
)

$Data = $Project | ForEach-Object {
    @{
        project = "$_"
    }
}

New-UDTable -Columns $Column -LoadData {
    $TotalCount = $Data.Count 
    $Data | Out-UDTableData -Page $EventData.Page -TotalCount $TotalCount -Properties $EventData.Properties
} -ShowSelection -Id 'Table'

$ProjectTable = Get-UDElement -Id "Table"
$ProjectSelected = "$( $ProjectTable.selectedRows.project -join ", " | Out-String )"
Show-UDToast -Message $ProjectSelected

$PermissionSelected = "$( $ProjectTable.selectedRows.permission.value -join ", " | Out-String )"
Show-UDToast -Message $PermissionSelected

I can already tell what I have isn’t completely ideal because it’s creating two separate strings vs a custom array but hopefully you get the idea.

Ultimately I’m trying to get the output to show the project and permission for every object.


Project | Permission

project1 | Administrator
project2 | Member


Thanks in advance!

Product: PowerShell Universal
Version: 1.4.6

I’d suggest using a calculated ID for the select and then accessing that directly.

    New-UDTableColumn -Property permission -Title Permissions -Render {
        New-UDSelect -Id "$($EventData.Project)_permission" -Option {
            New-UDSelectOption -Name 'Member' -Value 'Member'
            New-UDSelectOption -Name 'Administrator' -Value 'Administrator'
            New-UDSelectOption -Name 'Contractor' -Value 'Contractor'
        } -Id 'UDProjectSelect'
    }

Then you can use Get-UDElement.

(Get-UDElement -Id 'Project 1_permission').Value
1 Like