Product: PowerShell Universal
Version: 5.0.7
I’m sure this is a fairly simple thing, but I can’t find an example in the docs or the forums that seems applicable enough.
I just want to show a new Autocomplete element when a check box is changed.
I can have it display the toast message no problem (just for proving the if statement is working correctly), but getting a new element to show is difficult (at least for this PSU novice). It might be a limitation, and if it is… does anybody have any clever workarounds?
This app is for running a user termination, by default it should set the email forward to their manager, but occasionally they want it to go to someone else. I’d like to present the option to the user via the checkbox and the resulting autocomplete element so they can choose a different recipient.
New-UDCheckbox -Id 'chkFwdToMgr' -Label 'Forward Email to Manager?' -OnChange {
$chkFwdElmnt = Get-UDElement -id 'chkFwdToMgr'
if ($chkFwdElmnt.checked) {
New-UDAutocomplete -id "acFwdTo" -Label 'Forward to who?' -OnLoadOptions {
get-aduser -filter "Name -like '*$body*' -and Enabled -eq 'True'" | Select-Object -ExpandProperty Name | convertto-json
}
Show-UDToast "$chkFwdElmnt"
}
}