I am trying the get the result from the select box and then get the value to be processed by my sql query next. However I just cannot get the value out? I have read the document on New-UDSelect and tried a few on the forum , still not working.
Hello @qy2009 I cannot answer your direct question, however I can show you something I contributed a while back Ironman Software Marketplace - UniversalDashboard.UDSelector which shows you how to do this…If you only want a single selection then you can use Ironman Software Marketplace - UniversalDashboard.UDSingleSelector I do need to get round to updating this component building it directly for PSU…but this should work for you, so kind of answering your question on how I would and have gone about doing this exact thing in the past…I hope this helps
@psDevUK I love your UniversalDashboard.UDSingleSelector, the UI looks soooo nice
I have read the document, looks like it is for UDSelector? Also, is there a way to set the default selection?
I have tried the UDSingleSelctor, however it still didn’t work ;(
I need the value to be set inside the SQL query.
Here is my code:
Import-Module dbatools
$sqlserver = ‘xxx’
$database = ‘xxx’
$siteserver = ‘xxx’
$sitecode = ‘xxx’
New-UDSingleSelector -Id “stuff” -options {
@{ value = "patchserver"; label = "Server Patchlist" },
@{ value = "internalpatch"; label = "Internal Workspace" },
@{ value = "externalpatch"; label = "External Workspace" },
@{ value = "serverbaseline"; label = "Server Baseline" }
@{ value = "workstationbaseline"; label = "Workstation Baseline" }
I can put an example together on getting the value…there is an easier way to do the SQL stuff…This drop down list can handle thousands of results from SQL…Need to find a script I was using…there is a lot of info on this thread on the forum:-
Boom…so glad I document stuff…please see the SQL sample in this README
Hi @psDevUK
I was using the New-UDSingleSelector, and that one doesn’t have “-Selected” parameter?
also, how can I get the value out? I was using
$selection = (Get-UDElement -id “stuff”).Attributes.selectedOption
and
$selection = (Get-UDElement -id “stuff”).Attributes.selectedOption | ConvertTo-Json | ConvertFrom-Json
I understand there was issues using this and PS7. So first question is are you using powershell 7?
Just want to verify that from using the above code, you did give the -id paramater the name "stuff"
The other week I finished my job…so I need to get PSU install on the wifes laptop as she got x64 and I am still on x86
I got a good few weeks till I start my next job, so I think it would make sense for me to rebuild both these components, include the additional -selected parameter for the single selection…I am also then hoping the light dark mode will work with it…
I know people do have this working in PSU, but I only ran it in UD…will attempt on Monday to get this up and running on the wifes laptop…so I can send an official answer…
You did try the function yeah?
Hi @qy2009 I have dealt with people running into issues whilst trying to use this component, but they seem to come through in the end, and get it working…I am seeing some slight syntax differences from how you are trying to read the value to how I have it documented in the link in the above post to my github page. I will attempt to get PSU running on my wifes laptop tomorrow and post a full on solution, if the demo files in the documentation are not working, as that was written for UD not PSU, so some slight adjustments might be required…I cannot promise this though as I also got four daughters to entertain tomorrow as well
Not sure if the code I got in this post will help?
@psDevUK I realized that we were talking different things, I was testing with the UD-SingleSelector the whole time, and you were talking about the UD-Selector. I am really sorry about that. My mistake
I found these two codes can get the value out from the selection:
Maybe you can update the document on UD-SingleSelector in future ? Then less people will be confused. Also, it will be really appreciated if you can add the default value parameter for UD-SingleSelector.
Enjoy your time with your family please! Family always come first
At least I can start working on the next few things now.