Returning a variable for toast display output

hi - i’m trying to output a text but i just couldn’t figure it out. anyone care to help out? :slight_smile:

    New-UDDynamic -Id 'CollectionElement' -Content {
        if ( $Session:Collection ) {
            New-UDSelect -Id 'Collections' -DefaultValue 'Collections' -Option { $Session:Collection } -OnChange {
                $SelectedCollection = Get-UDElement -Id 'Collections'
                Show-UDToast -Id 'SelectedCollectionItem' $SelectedCollection.Value

            Sync-UDElement -Id 'ShowCollectionItem'
        }

        $Item = Get-UDElement -Id 'Collections'
        Show-UDToast -Id 'ShowCollectionItem' -Message "$( $Item | Out-String )"  

i already tried adding ‘value’ ($Item.value) to the last toast but to no avail.

You can use the $EventData parameter to get the currently selected value.

    New-UDDynamic -Id 'CollectionElement' -Content {
        if ( $Session:Collection ) {
            New-UDSelect -Id 'Collections' -DefaultValue 'Collections' -Option { $Session:Collection } -OnChange {
                Show-UDToast $EventData
        }