Simple AD Query updating a new "card"

I feel like I may be missing a simple thing. This is my code that seems to work

New-UDInput -Title "Computer Lookup"  -Endpoint {
    param($user)
         $search = "*$user*"
        New-UDInputAction -Content @(
            New-UDGrid -Title "Results" -headers @("Computer Name", "Description") -properties @("Name","Description") -endpoint {
               
                $cn = get-adcomputer -properties * -filter { Description -like $search } | Select Name, Description
                $cn | Out-UDGridData
            }
        )
            
}
}

With that said, it updates the current card, I don’t really want it to do that. I’d really prefer it to update or create a new card with the results, leaving my Input available to reuse, without refreshing.

Can someone help?

Hi @Tuxhedoh,
Welcome to the UD Forums!

Try storing the results in the $session variable, and reference that on a grid further down the page.
See the example:

Haven’t tested it, but should work!
Have a good one!

1 Like

That worked. Can you explain why? Also, any suggestions if I want the Results grid to not be displayed until results are ready?

Hi again @Tuxhedoh
New-udinputaction appends the existing content.
If you store the results in the AWESOME $session: variable, it’s avaliable to all endpoints for that session.
Calling “sync-udelement” with the ID of the grid, forces the grid to update once the processing is completed.

As for hiding it until ready…
updated the github:


The “container” will check if anything is set in the session variable, and show the grid if exists. The sync-element is pointed to the container, which in turn will force all children to sync.

Again… not testet self (A)

Thanks for the prompt reply. Unfortunately the un-hide did not work, though I understand the logic that you’re going for. :smiley: I’m unsure how to debug.

Hi again @Tuxhedoh!

Check the github for a fully functional, and tested version:


Now, it won’t hide the grid until you manually set the session variable to null and refresh the container, but i added a button to hide it.
Just ask if anything doens’t make sense :slight_smile:

1 Like