Product: PowerShell Universal
Version: 3.8.8
Hi!
I have to the following dashboard. Whenever I select a radio button, it updates the choices in the select field. Unfortunately, it try’s to the same one multiple times as I receive the following error when selecting a radio button:
Also, the select box always just shows one option, even though there should be 2 at the moment. It shows that it adds 2 options, but I can only select one option.
Any ideas?
$Session:ClientOptions = @()
New-UDBackdrop -Id 'backdrop' -Content {
New-UDTypography -Text "Loading..." -Variant h2
}
New-UDCard -Title 'Send mail' -Content {
New-UDForm -Content {
New-UDRadioGroup -Id "message_category" -Label "Message category" -Content {
New-UDRow -Columns {
New-UDColumn -LargeSize 1 -Content {
New-UDRadio -Label 'All users' -Value 'All users'
}
New-UDColumn -LargeSize 1 -Content {
New-UDRadio -Label 'Security' -Value 'Security'
}
New-UDColumn -LargeSize 1 -Content {
New-UDRadio -Label 'Management' -Value 'Management'
}
}
} -OnChange {
Set-UDElement -Id 'backdrop' -Properties @{
open = $true
}
$halo_clients = Invoke-PSUScript -Script HaloHelpers/GetHaloCustomersWithMailContacts.ps1 -Wait
if ($halo_clients.count -lt 10) {
Show-UDToast -Message "Halo API returned an error" -Duration 3000
}
$message_category = (Get-UDElement -Id 'message_category').value
if ($message_category -eq "All users") {
$halo_clients = $halo_clients | Where-Object -FilterScript { $_.Mailcontactallusers -ne $null }
}
if ($message_category -eq 'Security') {
$halo_clients = $halo_clients | Where-Object -FilterScript { $_.Mailcontactsecurity -ne $null }
}
if ($message_category -eq "Management") {
$halo_clients = $halo_clients | Where-Object -FilterScript { $_.Mailcontactmanagement -ne $null }
}
Show-UDToast -Message "Filtered all clients. Remaining: $($halo_clients.count)" -Duration 3000 #Shows 2
$Session:ClientOptions = $null #Trying to clear things up
$Session:ClientOptions = @() #Trying to clear things up
foreach($halo_client in $halo_clients) { #$halo_clients.count usually = 2
$Session:ClientOptions += New-UDSelectOption -Name $halo_client.name -Value $halo_client.id
Show-UDToast -Message "Added $($halo_client.name)" -Duration 3000 #appears 2 times, with individual names
}
Show-UDToast -Message "Options: $($Session:ClientOptions.count)" -Duration 5000 #shows 4!
Sync-UDElement -Id 'dySelect'
Set-UDElement -Id 'backdrop' -Properties @{
open = $false
}
}
New-UDDynamic -Id 'dySelect' -Content {
New-UDSelect -Id 'select_clients' -Label 'Select Clients' -Option { $Session:ClientOptions }
}
New-UDCheckbox -Id 'chkSimulate' -Label 'Simulate (Do not actually send)' -Checked $true
} -OnSubmit {
Show-UDModal -Content {
New-UDTypography -Text "Submitted"
} -Footer {
New-UDButton -Text "Close" -OnClick { Hide-UDModal }
} -Persistent
}
}