Product: PowerShell Universal
Version: 5.6.7
I am building a table with data pulled from a SQL DB. In one of the columns I am creating a button that will open a modal showing a table build from the SQL data. Here is a sanitized version of one of the entries
[
{
"Id": "sip:user@domain.com",
"MakeCalls": true,
"ManageSettings": true,
"ReceiveCalls": true
},
{
"Id": "sip:user@domain.com",
"MakeCalls": false,
"ManageSettings": true,
"ReceiveCalls": true
}
]
And this is where I am building the button/modal/column
New-UDTableColumn -Property Delegates -Title Delegates -Render {
if ("" -ne $eventdata.Delegates){
New-UDButton -id "btn_DelegateData" -Text "View Delegate Info" -Color secondary -OnClick {
Show-UDModal -Content {
$DelegateData = $eventdata.Delegates | ConvertFrom-Json
$DelegateTableColumns = @(
New-UDTableColumn -Property ID -Title "Delegate"
New-UDTableColumn -Property MakeCalls -Title "Can Make Calls" -Render {
if ($eventdata.MakeCalls -eq $true) {
New-UDIcon -Icon Circle-Check -Color Green
}
Else {
New-UDIcon -Icon circlexmark -Color Red
}
}
New-UDTableColumn -Property ManageSettings -title "Can Manage Settings" -Render {
if ($eventdata.MakeCalls -eq $true) {
New-UDIcon -Icon Circle-Check -Color Green
}
Else {
New-UDIcon -Icon circlexmark -Color Red
}
}
New-UDTableColumn -Property ReceiveCall -Title "Can Receive Calls" -Render {
if ($eventdata.MakeCalls -eq $true) {
New-UDIcon -Icon Circle-Check -Color Green
}
Else {
New-UDIcon -Icon circlexmark -Color Red
}
}
)
New-UDTable -id "tbl_DelegateData" -Columns $DelegateTableColumns -Data $DelegateData
}
}
}
Else {
New-UDTypography -Text "No Delegations"
}
}
The problem I am getting is that when the button is clicked it only uses the data from the last row in the table. So if I have 6 users with delegation only the last delegation info will be used for all 6 buttons. Here is what is shown regardless of what data should be there.
I have a similar button elsewhere in the table built similarly that works correctly. The raw data in the DB looks like this
{
"ForwardingTarget": "+1123456789",
"ForwardingTargetType": "SingleTarget",
"ForwardingType": "Immediate"
}
and the column is built like this
New-UDTableColumn -Property Forwarding -Title "Forwarding Settings" -Render {
if ("" -ne $eventdata.forwarding){
New-UDButton -id "btn_$($eventdata.userprincipalname)_forward" -Text "View Forwarding Info" -Color secondary -OnClick {
Show-UDModal -Content {
$ForwardData = $eventdata.forwarding | ConvertFrom-Json
$forwardTableColumns = @(
New-UDTableColumn -Property ForwardingTarget -Title "Forward To"
New-UDTableColumn -Property ForwardingTargetType -Title "Forwarding Target Type"
New-UDTableColumn -Property ForwardingType -title "Forwarding Type"
)
New-UDTable -id "tbl_ForwardData" -Columns $forwardTableColumns -Data $ForwardData
}
}
}
Else {
New-UDTypography -Text "No Forwarding"
}
}
That one works correctly, so I’m not sure why the delegation one isn’t working.