How to get and process selected rows of a (dynamic) table?

Hi everyone,
I’m new to PSU and have just started testing the product.

I want to write smaller apps/scripts with PowerShell, but make them available via a website. PSU sounds promising in this regard.
Scripts aren’t such a problem. But the interaction between graphical PSU components and the script is something I find very difficult - at the moment.

As a beginner, I lack practical example code to guide me. Therefore, I’m currently finding it very difficult to understand the connections and create the conditions necessary to design an app according to my ideas.

I’ve currently built an app where I can select something from a dropdown field. Based on the selection, group members from the selected AD group are read and displayed in a dynamic table.

Now i can select individual or all entries from the table. But how can I further process the selection? For example, I would like to have a button/link that, when clicked, opens Outlook and sends an email to all selected rows.

Thank you for your help!

       New-UDCard -Content {
            $Columns = @(
<#
            New-UDTableColumn -Property Test -Title "Mail schreiben" -Render{
                $Test = $EventData.mail
                Write-Host $Mail
                New-UDLink -Id "btn$($EventData.Mail)" -Text "Mail schreiben" -Url "mailto:'$Test'" -Style @{ 'color' = 'red' } -Underline "hover"
            }
#>
            New-UDTableColumn -Property Surname -Title "Nachname" -IncludeInExport -DefaultSortColumn
            New-UDTableColumn -Property GivenName -Title "Vorname" -IncludeInExport
            New-UDTableColumn -Property SamAccountName -Title "Anmeldekürzel" -IncludeInExport
            New-UDTableColumn -Property Mail -Title "Mail" -IncludeInExport
            New-UDTableColumn -Property telephoneNumber -Title "Telefon" -IncludeInExport
            New-UDTableColumn -Property Mobile -Title "Mobil" -IncludeInExport
            )
            New-UDDynamic -Id "dynTable" -Content {
                if ($Page:DVS){
                    New-UDTable -Id "Test" -Columns $Columns -Data $Page:DVS -Sort -Dense -ShowSelection -OnRowSelection {Sync-UDElement -Id 'Selected'}
                }
            }
            New-UDDynamic -Id "Selected" -Content {
            $Value = (Get-UDElement -Id 'Test').Value
            Write-Host "Value "$Value
            }
        }

Product: PowerShell Universal
Version: 5.5.3

got it :smiling_face_with_three_hearts:

        New-UDCard -Content {
            $Columns = @(
            New-UDTableColumn -Property Surname -Title "Nachname" -IncludeInExport -DefaultSortColumn
            New-UDTableColumn -Property GivenName -Title "Vorname" -IncludeInExport
            New-UDTableColumn -Property SamAccountName -Title "Anmeldekürzel" -IncludeInExport
            New-UDTableColumn -Property Mail -Title "Mail" -IncludeInExport
            New-UDTableColumn -Property telephoneNumber -Title "Telefon" -IncludeInExport
            New-UDTableColumn -Property Mobile -Title "Mobil" -IncludeInExport
            )
            New-UDDynamic -Id "dynTable" -Content {
                if ($Page:DVS){
                    New-UDTable -Id "Test" -Columns $Columns -Data $Page:DVS -Sort -Dense -ShowSelection -OnRowSelection {Sync-UDElement -Id 'Selected'}
                }
            }
            New-UDDynamic -Id "Selected" -Content {
                if ($Page:DVS){
                    $TableData = Get-UDElement -id "Test"
                    $AllMailAddressesInOneString = $TableData.selectedRows.Mail
                    $MailAddresses = @()
                    foreach ($i in $AllMailAddressesInOneString){
                        $MailAddresses += $i+$Delimiter
                    }
                    if ($MailAddresses){
                        New-UDButton -Id "Mailbutton" -Text 'Email senden' -Icon (New-UDIcon -Icon "envelope") -Size "medium" -Style @{ backgroundColor = 'red'} -OnClick { Invoke-UDRedirect -Url "mailto:$MailAddresses" }
                    }
                }
            }
        }