$EventData.xxx not consistently working as expected in New-UDTableColumn with logic

I am seeing odd behavior when using New-UDTableColumn and displaying the $EventData. I have two columns I am processing from the same object and one works and displays find and the other does not - it does show the value in the UDToast but does not include it on the table.

I have also tried different ways of tackling this including moving the logic part outside of the New-UDTableColumn block and instead using a New-UDTableColumn with -Render else just New-UDTableColumn to get the desired effect and it reverses the issue where the UDSelect then doesn’t show the EventData as desired.

This behaved the same in PSU 2.1.2 and I updated to PS 2.2.1 hoping it might fix it but it did not.

Thanks in advance.

New-UDTableColumn -Property BlockSizeKB -Title 'BlockSizeKB' -Align Center -Render {
  $BlockSizeKBList = @(
    ' '
    '1'
    '2'
    '4'
    '8'
    '16'
    '32'
    '64'
  )
  if ($EventData.BlockSizeKB -match '^\d+') {
    Show-UDToast -Message $EventData.BlockSizeKB -Duration 10000
    $EventData.BlockSizeKB
  } else {
    New-UDSelect -Id "BlockSizeKBList_$($EventData.DiskNumber)" -Option {
      $BlockSizeKBList | ForEach-Object {
        New-UDSelectOption -Name $_ -Value $_
      }
    } -DefaultValue ' '
  }
}
New-UDTableColumn -Property PartitionStyle -Title 'PartitionStyle' -Align Center -Render {
  $PartitionStyleList = @(
    'RAW'
    'MBR'
    'GPT'
  )
  if ($EventData.PartitionStyle.ToUpper() -eq 'RAW') {
    New-UDSelect -Id "PartitionStyleList_$($EventData.DiskNumber)"-Option {
      $PartitionStyleList | ForEach-Object {
        New-UDSelectOption -Name $_ -Value $_
      }
    } -DefaultValue $EventData.PartitionStyle.ToUpper()
  } else {
    $EventData.PartitionStyle
  }
}

Toast:
image

Product: PowerShell Universal
Version: 2.2.1

Can you try putting the value in a typography to see if that helps?

New-UDTypography -Text $EventData.BlockSizeKB
1 Like

image

Thanks. That did it. Weird that it wasn’t needed in the other column basically doing the same thing.

That is weird. Is BlockSizeKB an int? Maybe it’s cuz partition style was a string.

It originally is an int but in the object used for table it is converted to a string.

$newObject = [PSCustomObject]@{
  Name               = $systemLookupData.ServerFQDN
  Volume             = $volume
  VolumeName         = $volumeName
  SizeGB             = [string]$SizeGB
  FreeSpaceGB        = [string]$FreeSpaceGB
  PercentFree        = $PercentFree
  BlockSizeKB        = [string]$blockSizeKB
  PartitionStyle     = $partitionStyle
  DiskNumber         = [string]$diskItem.Number
  IsBoot             = [string]$diskItem.IsBoot
  IsSystem           = [string]$diskItem.IsSystem
  IsOffline          = [string]$diskItem.IsOffline
  OfflineReason      = $OfflineReason
  Location           = [string]$diskLocation
  TargetID           = [string]$disklTargetID
  NumberofPartitions = $diskitem.NumberofPartitions
  HealthStatus       = $diskHealthStatus
}
$diskObject += $newObject

Hmmm weird. Glad the work around works.

2 Likes