Remove-UDElement Error

Product: PowerShell Universal
Version: 3.9.13

I am attempting to toggle between a few tables. The initial table is always rendered by the New-UDAutoComplete but each table change after that is via its respective button. I get an error using Remove-UDElement. Any ideas on how to resolve? Thanks!

I can reproduce this. I worked around it by using Sync-UDElement rather than Remove-UDElement on the UserTable. Since you are updating session variables, it will reevaluate and then hide the user table.

    $Session:Table = "User"
    New-UDButton -OnClick {
        $Session:Table = "Group"
        # Remove-UDElement -Id 'UserTable'
        Sync-UDElement -Id 'UserTable'
        Sync-UDElement -Id 'GroupTable'
    } -Text 'Sync'

    New-UDDynamic -Id 'GroupTable' -Content {
        if ($Session:Table -eq 'Group') {
            New-UDTable -Data (Get-Process | Select Name)
        }
    }

    New-UDDynamic -Id 'UserTable' -Content {
        if ($Session:Table -eq 'User')
        {
            New-UDTable -Data (Get-Process | Select ID)
        }
    }

thank you @adam
Is this using the -onChange New-UDAutoComplete or just using buttons?

I am going to test a bunch now :slight_smile:

Worked perfectly, even with the New-UDAutoComplete onchange. What a phenomenal product this is!

1 Like