Hi guys,
I am trying out the new version of the dashboard for a POC and had the idea of a lookup that updates a table. This table then has a button for each of the items found and will return the ID (for future logic). On the first run this works, however when I look up something else it throws a React error!
First off, shouldn’t these kinds of errors be caught somewhere and converted or translated into more relevant messages?
My best guess is that the way i’m defining my columns is not correct since it gets called everytime a new search is performed?
The code below:
#Logic for defining custom columns for all properties in a PSObject
Function Get-TableColumnsFromProperties ($object) {
$members = Get-Member -InputObject $object -MemberType NoteProperty
$result = foreach ($member in $members) {
New-UDTableColumn -Property $member.Name -Title $member.Name
}
return $result
}
#Gets product object from search bar
$search = Get-Product -productName $Session:ProductSearch
if ($search) {
#puts all the properties from the object into columns (do i have to do this myself if i want to have 1 extra custom column?
$columns = Get-TableColumnsFromProperties -object $search[0]
#Add the column with button just like i found in the documentation
$columns += New-UDTableColumn -Property 'Lookup' -Title 'Opzoeking' -Render {
New-UDButton -Text 'Opzoeking' -OnClick {Show-UDToast -Message $EventData.ProductCode - Duration 1000}
}
New-UDTable -Title 'Producten info' -Data $search -Icon (New-UDIcon -Icon ShoppingCart) -Columns
$columns
$Session:ProductSearch = $null
}
So this error pops up when I look up a value after successfully looking up the first one.
Product: PowerShell Universal
Version: 1.4.6