Tables and Buttons inside UDDynamic are no longer updating

Product: PowerShell Universal
Version: 4.0.9

Hey PSU folks,

I have numerous web apps where you’re prompted to enter a username and click a button to search for matching users. This triggers a Sync-UDElement -ID ‘ID of the UDDynamic’. This will get the username from the text box and lookup the possible user matches in AD. If we don’t find users, we populate $noUsers with a message. Otherwise, we build a table and assign it a variable of $table, and we build the button to take actions on the selected user in the table and give it a variable like $button_DisconnectUser. At the end of all this we say

if ($noUsers) {
    $noUsers
}

else {
    $table
    $button_DisconnectUser
}

So, if we don’t find possible users, we display the message we set in $noUsers. Else if we do find possible users, we display the $table and the $button_DisconnectUser.

The issue I’m having is the $table and $button_DisconnectUser are no longer being updated when we search for another user. I’ve used Show-UDToast at each level inside the UDDynamic to prove all actions are being performed and we have updated data, but $table and $button_DisconnectUser are not being updated on screen; we’re left with the table and button from the previous username search.

I’ve tried pulling the table and button out of variables; just using New-UDTable and New-UDButton, without assigning to $table and $button_DisconnectUser variables. I’ve tried removing the if/else at the end and just having it write the table and button at a higher level. Nothing I try is updating the table and button inside the UDDynamic.

This has worked great for the past couple of years, but I noticed this problem after upgrading to 4.0.1. I upgraded to 4.0.9 hoping it would be fixed, but still having the problem.

To note, the tables and buttons are created and work properly with the first username search. After that though, they do not update. A refresh will of course reset everything and work for a single search.

Any ideas?

Thanks,
Rob

I have been able to track this down to an issue with the table’s -Id.

This is how I’ve always written the tables in my UDDynamics, give a static entry for the Id such as -Id ‘table_Users’

It works on the first search, and normally will update on subsequent searches. I’ve verified I’m getting updated search data in the $table_data variable. But the table on-screen is not being updated, and the button is not getting udpated data from Get-UDElement -Id ‘table_Users’.

$table = New-UDTable -Id 'table_Users' -Data $table_data -Columns $table_columns -ShowSort -Dense -ShowPagination -PageSize 10 -ShowSelection -DisableMultiSelect

$button_DisableUser = New-UDButton -Id 'button_DisableUser' -Text 'Disable User' -Color Primary -OnClick {
    $values = (Get-UDElement -Id 'table_Users').SelectedRows

When I apply a work around by assigning a random number to the table’s Id, it works! In production I’d use a session variable and increment with ++, but for this example I just used Get-Random. Using the below, the table will refresh on-screen, and the button will be able to act on the select user from the refreshed table.

$i = (1..20) | Get-Random
$tableId = "table_Users$i"
$table = New-UDTable -Id $tableId -Data $table_data -Columns $table_columns -ShowSort -Dense -ShowPagination -PageSize 10 -ShowSelection -DisableMultiSelect

$button_DisableUser = New-UDButton -Id 'button_DisableUser' -Text 'Disable User' -Color Primary -OnClick {
    $values = (Get-UDElement -Id $tableId).SelectedRows

Is this a bug, or was there a change to where this is now expected behavior? I don’t really want to have to update dozens of web apps and have to write new ones with this workaround.

Thanks,
Rob