Table $body not being populated

Hey Guys,

Have not posted in a while and probably running a old version of PU but when I have the following:

New-UDDynamic -Id 'CitrixSessions' -Content {
			$citrixsessionsColumns = @(
				New-UDTableColumn -Property UserName -Title "User name"
				New-UDTableColumn -Property SessionState -Title "Session State"
				New-UDTableColumn -Property App -Title "Application"
				New-UDTableColumn -Filter $false -Property session -Title "End Session" -Render { 
					$Item = $Body | ConvertFrom-Json
					New-UDButton -Id "btn$($Item.SessionKey)" -Text "End Session" -OnClick {
						Show-UDModal -Content {
							New-UDTypography -Text "Waiting for session to end:  "
							New-UDProgress -Circular -Color Red
							New-UDDynamic -id "WaitForSessionEnd" -content {
								Do{
									$issessionlive = if (Get-BrokerSession -AdminAddress $AdminAddress | where {$_.sessionkey -eq $item.SessionKey}) {$true}else{$false}
								} while ($issessionlive -eq $true)
								Hide-UDModal
								Get-CitrixSessions
							}
						}
					}
				}
			)
			New-UDTable -filter -Data $session:citrixsessions -columns $citrixsessionsColumns 
		}

This code used to work, however $Item is currently Null so it cant find the session I am looking for, Have I missed something? Or is there something I can do to fix it as it does not seem to pull data from the $body.

The display of the table works fine.

Try using $EventData rather than body.

New-UDDynamic -Id 'CitrixSessions' -Content {
			$citrixsessionsColumns = @(
				New-UDTableColumn -Property UserName -Title "User name"
				New-UDTableColumn -Property SessionState -Title "Session State"
				New-UDTableColumn -Property App -Title "Application"
				New-UDTableColumn -Filter $false -Property session -Title "End Session" -Render { 
					$Item = $EventData
					New-UDButton -Id "btn$($Item.SessionKey)" -Text "End Session" -OnClick {
						Show-UDModal -Content {
							New-UDTypography -Text "Waiting for session to end:  "
							New-UDProgress -Circular -Color Red
							New-UDDynamic -id "WaitForSessionEnd" -content {
								Do{
									$issessionlive = if (Get-BrokerSession -AdminAddress $AdminAddress | where {$_.sessionkey -eq $item.SessionKey}) {$true}else{$false}
								} while ($issessionlive -eq $true)
								Hide-UDModal
								Get-CitrixSessions
							}
						}
					}
				}
			)
			New-UDTable -filter -Data $session:citrixsessions -columns $citrixsessionsColumns 
		}
1 Like

Hey Adam,

Thanks very much, this is now working. So going forward I should use $EventData rather than $Body?

Yes. I would suggest to use $EventData