Search using element

Product: PowerShell Universal
Version: 2.7

I had this working on prior versions of UD (I think even perhaps 2.4), but this is no longer getting the element. I’m trying to have a search box that then returns a table of results:

New-UDColumn -SmallSize 10 -Content {

                            New-UDCard -Id "CardSearchUser" -Content {

                                $SearchIcon = New-UDIcon -Icon search

                                New-UDTextbox -Id "txtSearch" -Label "Search" -Placeholder "Search for a user by name" -Icon $SearchIcon

                            }

                        }

                        New-UDColumn -SmallSize 2 -Content {

                            $SearchIcon = New-UDIcon -Icon Search

                            New-UDButton -Id "btnSearch" -Text "Search" -Icon $SearchIcon -OnClick {

                                $Element = Get-UDElement -Id "txtSearch"

                                $Value = $Element.Value

                                Show-UDToast -Message $Value -Duration 15000

                                Set-UDElement -Id "results" -Content {

In this case, I’m not getting anything in the Element. Am I doing something wrong with this?

Disclaimer: I’m running the latest 2.8 build

I don’t see this issue.

New-UDDashboard -Title 'Test' -Content {
    New-UDCard -Id "CardSearchUser" -Content {
        $SearchIcon = New-UDIcon -Icon search
        New-UDTextbox -Id "txtSearch" -Label "Search" -Placeholder "Search for a user by name" -Icon $SearchIcon
    }

    $SearchIcon = New-UDIcon -Icon Search
    New-UDButton -Id "btnSearch" -Text "Search" -Icon $SearchIcon -OnClick {
        $Element = Get-UDElement -Id "txtSearch"
        $Value = $Element.Value
        Show-UDToast -Message $Value -Duration 15000
    }
}

Hmm, this is strange. I setup a dashboard with just that after upgrading to 2.8 and it still isn’t getting the variable. I then setup a new VM with just this and it worked perfectly. Now, how do I determine what might be causing it to not work on one server?

Here are a few details on that server:

  • Server 2019 Datacenter
  • UD 2.8
  • With the test dashboard, I have 7 dashboards running on it
  • I have AAD auth, but my test/sample sites don’t require auth

I’m at a bit of a loss as to why this isn’t working on this server.

That is strange. Did you use the same 2.8 installer or were they two different builds?

I installed today’s build on both of them.

Strange. This works by sending a request from the server over the connected web socket and then the component sends an HTTP POST with the data back to the server.

I would suggest opening F12 and viewing the network tab to see if that exchange is happening. I’m happy to review a HAR file if you export it from the browser.

After successfully testing a page with two tabs, each with a table and two buttons executing tasks based on the selected rows, I checked in tonight to bask in the success only to find the intermittent issue was back.(Sometimes the selected row data is captured from the Get-UDElement command, other times the value was null for one or both buttons.) I then upgraded to 2.8 and attempted breaking one of the tables out into a separate page of the dashboard and still encountered the issue. Will continue poking with sharp sticks…

1 Like

Having a similar issue with selecting rows on a table. Get-UDElement isn’t returning anything on one page, same logic and it works on another.

I’m curious if others who are having this issue might be setup in a similar manner. I did some testing in Dev and found that the code above worked. Then, I was doing some other changes and changed the service to run under a Windows service account (domain). When I made that change, Get-UDElement seemed to stop working again.

I’m running the service as a service account, but it works intermittently - i.e. one page it works, one it doesn’t.

@rachsngltn - Was this working fine for you on previous versions?

I have another user that upgraded from 2.3.1 to 2.7.2 and Sync-UDElement on a New-UDDynamic is much, much slower for them. I’m wondering if something changed somewhere in-between those builds that’s affecting the UDElement cmdlets.

I just pushed 2.8.1 to production. I adjusted the Get-UDElement timeout from 1 second to 5 to see if we can get some more consistency. I’m not convinced that’s what’s happening in your environments but feel free to see if that’s more consistent.

This also fixes an issue where elements a blocking garbage collection call was being invoked to was causing elements to have a 500ms to 2s delay in certain circumstances. I don’t know if this was affecting Get-UDElement. I don’t think it was.

Thanks. I updated to 2.8.1 and am having it come through sometimes, but still not 100%. I probably see it happening about 50-60% of the time, which is an improvement.

I’m running a 2.8.2 build that should greatly improve the performance of Get-UDElement. From what I can tell, CPU contention is causing this issue. I stood up a D2s v4 Azure VM and am running it in Kestrel. I was able to reproduce this issue pretty consistently by just clicking a button a bunch of times.

I’ve made some changes to how we serialize Get-UDElement requests, handle web socket messages and increased the number of available runspaces and now I can no longer reproduce this issue.

@dkkazak - I hope this resolves your issue but I’m still a bit concerned about the overall performance of your PSU instance. Feel free to try the nightly build.

@rachsngltn @Wa1tfor1t

The nightly build will be available in about 30 minutes for 2.8.2.

1 Like

After installing the latest version I now receive errors in the dashboard log;see below. If I revert to an earlier version of the framework 3.9.0 or 3.9.3 I no longer receive the error message, but the output is still null. Also found the Show-UDToast no longer works with the latest UniversalDashboard framework, works reverting to a previous version.

Feb 12, 2022 1:44 PM An error occurred: Cannot bind argument to parameter ‘InputObject’ because it is null.

Endpoint: 3e6667a7-933b-4098-97b4-f680971f2c40

Session: c2a4077b-043a-4b16-b22a-fb68b8f9f487, User: DOMAIN\User

Stack Trace:

  • Cannot bind argument to parameter ‘InputObject’ because it is null. at 3e6667a7-933b-4098-97b4-f680971f2c40:6569

  • 3e6667a7-933b-4098-97b4-f680971f2c40:165

  • 7df17da0-e4f5-47bc-a4b5-7b53a9f09bc1:142

Feb 12, 2022 1:44 PM C:\inetpub\wwwroot\PowerShellUniversal\Cmdlets\Universal.psd1

Feb 12, 2022 1:43 PM An error occurred: Cannot bind argument to parameter ‘InputObject’ because it is null.

Endpoint: 3305b723-188d-4f78-a33c-97dcbbebb757

Session: c2a4077b-043a-4b16-b22a-fb68b8f9f487, User: DOMAIN\User

Stack Trace:

  • Cannot bind argument to parameter ‘InputObject’ because it is null. at 3305b723-188d-4f78-a33c-97dcbbebb757:6562

  • 3305b723-188d-4f78-a33c-97dcbbebb757:158

  • 7df17da0-e4f5-47bc-a4b5-7b53a9f09bc1:142

Also running under a service account and was getting intermittent success.

The error is really just the same thing happening (Get-UDElement failing to respond in time) but I need to clean it up so either there is a valid error message, or it returns null like before.

There is certainly something I’m missing because I just tried again and installed the PSU 2.8.2 nightly build and this is my experience.

getudelement3

I’m still running PSU on the Azure D2s VM with 1 CPU and 8 GB RAM. It takes about 200ms to run the OnClick.

image

The profiler indicates it’s mostly spending that time executing PowerShell script.

If I click really rapidly it will need to open need runspaces. This causes a more delayed response but once enough runspaces have opened, it no longer does this.

My dashboard is super simple.

New-UDDashboard -Title 'Test' -Content {
    New-UDButton -Text 'Click' -OnClick {
        Show-UDToast (Get-UDElement -Id "test").Value
    }

    New-UDTextbox -Id 'test'
}

I would love to schedule a call sometime to look at your environment.

I installed 2.8.2 nightly today and it is definitely more reliable for the Get-UDElement and I’m not seeing the error. As you mentioned, it does still seem slow, but is at least returning the value.

Unfortunately, I had to downgrade to 2.7.4 as I have one page where it crashes whenever I load that page with 2.8. This page works reliably on 2.7.4 and consistently crashes on any 2.8 version.

Ok. I guess that’s some progress. I was able to improve the performance a bit more (25%ish). That will make it into the next build.

The crash is interesting. Is there any way you could email me the contents of that page so I can review what’s happening in it?

Any chance you are using ChartJS? I had the same issue with some pages crashing until I manually installed UniversalDashboard.Charts - 1.3.2. Version 1.3.3 was giving me grieve and even though the changelog says 2.8.1 includes version 1.3.2, I found version 1.3.3 installed.