Hi all
Firstly, I love this product and have been playing with it for several weeks, having been reading the forums for much of today it’s great to see what a healthy community you have here! I’m a novice at best and I’m motivated to really cut my teeth on this product, I can see so many possibilities to create amazing and functional tools.
I’ve created a dashboard which has a Table i’m populating from SQL, it has several columns and that is all working fine, I’ve added a UDSelect dropdown (also from data in SQL) and now I want add/populate an additional column to my Table based on that selection, and this where I’m coming unstuck.
I’ve spent several hours now trying to wrap my head around this but I fear I’m just getting myself confused with some concepts and I would appreciate someone outlining what I need to achieve this.
I believe I need to use an Endpoint so that when the UDSelect is chosen that the Table is aware of the selection, here is my code that is using -Content
New-UDTable -Title “” -Headers @("Name ", “Parameter”, “Description”, “Setting”, “Last Updated”, “Other”) -Content {
$Data = @($Comparisons | Sort-Object -Property CommandName, CommandParameter | Where-Object { $.CommandFamily -eq $CommandFamily -and $.Datatable -eq $Datatable } | Select-Object CommandName, CommandParameter,
CommandParameterDescription, CommandParameterType, “Setting”, LastUpdated , “Other” )
#Step through each Object in the array and make it addressable
for($i=0;$i-le $Data.length-1;$i++){
##Test for array as cant handle them yet
if ($Data[$i].CommandParameterType -ne ‘Array’){
#Update the value of Setting from the template
$Data[$i].Setting = $CompanyData.($Data[$i].CommandName).($Data[$i].CommandParameter)
}
}
$Data | Out-UDTableData -Property @(“CommandName”, “CommandParameter”, “CommandParameterDescription”, “Setting”, “LastUpdated” , “Other”)
$Data = $null
}
The first part of the puzzle for me is to simply try and get the existing data showing in my table using -EndPoint instead of -Content, but changing to -Endpoint results in a blank table.
If I insert data manually here using PSCustomObject then it appears, after more digging I think this is related to the Runspaces being different for variables I’ve put in Memory, in the above you can see $Comparisons, it contains test data I’ve manually called from SQL.
I tried adding this $Cache:Comparisons = $Comparisons to the top of my script, I’ve added a button to test and it shows a Datatable.row so I know it’s seeing the data at this stage:
New-UDButton -Text “Check Session Info” -OnClick {
Show-UDToast -Message “$Cache:Comparisons”
}
Then updated the UDTable script block as follows:
New-UDTable -Title “” -Headers @("Name ", “Parameter”, “Description”, “Setting”, “Last Updated”, “Other”) -Endpoint {
$Data = @($Cache:Comparisons | Sort-Object -Property CommandName, CommandParameter | Where-Object { $.CommandFamily -eq $CommandFamily -and $.Datatable -eq $Datatable } | Select-Object CommandName, CommandParameter,
CommandParameterDescription, CommandParameterType, “Setting”, LastUpdated , “Other” )
Step through each Object in the array and make it addressable
for($i=0;$i-le $Data.length-1;$i++){
##Test for array as cant handle them yet
if ($Data[$i].CommandParameterType -ne ‘Array’){
#Update the value of Setting from the template
$Data[$i].Setting = $CompanyData.($Data[$i].CommandName).($Data[$i].CommandParameter)
}
}
$Data | Out-UDTableData -Property @(“CommandName”, “CommandParameter”, “CommandParameterDescription”, “Setting”, “LastUpdated” , “Other”)
$Data = $null
}
But my table is still Empty . I tried this too: New-UDEndpointInitialization -Variable $Comparisons but same result. I’m more then happy to read and research further but just feel I’m missing a fundamental concept, anyone able to give me some pointers?
Many thanks for taking the time to read my novel!