New-UDSelect DefaultValue doesn't work from a Variable

  • Product: PowerShell Universal
  • Version: 1.58
  • Dashboard Framework: Latest

Hi all

I cannot get the -DefaultValue option to work with a Variable, I can see the variable does match the New-UDSelectOption name and is available to the object by placing it in the New-UDSelect -Label, see below

$Session:CurrentSettingValue = $EventData.Setting                                                       
                                                    New-UDSelect -Label $Session:CurrentSettingValue  -Option {                                                            
                                                        New-UDSelectOption -name "True" -Value "True"
                                                        New-UDSelectOption -name "False" -Value "False"
                                                    } -DefaultValue $Session:CurrentSettingValue -OnChange {
                                                        #}             

image

However if i use a string it does work, ie

$Session:CurrentSettingValue = $EventData.Setting                                                    
                                                    New-UDSelect -Label $Session:CurrentSettingValue  -Option {                                                            
                                                        New-UDSelectOption -name "True" -Value "True"
                                                        New-UDSelectOption -name "False" -Value "False"
                                                    } -DefaultValue "False" -OnChange {
                                                        #}

image

I’ve tried formatting $Session:CurrentSettingValue as " $Session:CurrentSettingValue" & "$($Session:CurrentSettingValue)" and there is no change.

Any ideas?

Hello @MaCCa have a butchers at:-

As there is a demo there using default parameter hope this helps :slight_smile:

Uhh this is embarrassing but I found the problem! My SQL update that runs after the select was inserting a leading space into my values, omg, sorry for wasting all your time psDevUK :frowning:

2 Likes