Dynamically create a transfer lsit

Product: PowerShell Universal
Version: 3.7.13

Triying to dynamically create a transfer list with a list of computers from AD

    New-UDTextbox -id "tb_Hostname" -Label "Hostname"
    new-udhtml -Markup "<br>"
    New-UDButton -id "btn_Get" -Text "Get computers" -OnClick {
        $search = (Get-UDElement -Id "tb_Hostname").Value
show-udtoast -Message $search
        $session:computers = get-adcomputer -filter "name -like '$search'" -Properties name | select-object name
        Sync-UDElement -id "dyn_Computers"
    }
    New-UDDynamic -id "dyn_computers" -content {
        New-UDTransferList -Item {
            $session:computers | foreach-object {
                New-UDTransferListItem -Name $_.name -Value $_.name
            }
        } 
    } -LoadingComponent {
        new-udprogress -Circular -Color blue
    }

The transfer list never updates with the new information after a button press. I verified that $session:computers does contain the data I want. I currently do something similar with a UDSelect and it works. Is this possible with the transfer list?

Reviving this, I am having the same issue as well using version 4.2.12

I eventually did get this to work using code like this.

New-UDTextbox -id "tb_Hostname" -Label "Hostname" -onenter {
            Invoke-UDEndpoint -id "btn_Get" -session
        }
        new-udhtml -Markup "<br>"
        New-UDButton -id "btn_Get" -Text "Get computers" -OnClick {
            $search = (Get-UDElement -Id "tb_Hostname").value
            $session:computers = get-adcomputer -filter "name -like '$search'" -Properties name | select-object name
            Sync-UDElement -id "dyn_Computers"
        }
        New-UDDynamic -id "dyn_Computers" -Content {
            if ($session:computers){         
                New-UDTransferList -id "tlist_Computers" -Item {
                    foreach ($comp in $session:computers){
                        New-UDTransferListItem -Name $comp.name -Value $comp.name
                    }
                } -showsearch -alignment Left
            }
        } -LoadingComponent {
            new-udprogress -Circular -Color blue
        }
1 Like