Custom Functions inside of a UDgrid

So, i have begun experimenting with trying to change around my dashboard to reduce the number of active endpoints.

Currently, i have a ton of stuff built out like this:

That is an example and is the first item, there are 14-15 that do various things. To try and shift away from having around 15k endpoints active, i am trying to do this:

And I’m calling this in my page as such:

However when i try to do this, i am getting this error:

12:19:03 [Warn] ExecutionService Error executing endpoint 60d7d24d-3b12-4c13-86e0-0a1493487710. An item with the same key has already been added.

and that endpoint contains:

$Objects | ForEach-Object {
		Username = $_.UserPrincipalName
		Name     = $_.Name
		MoreInfo = Get-Details $_
		ResetPW  = $_.ResetPW
} | Out-UDGridData

I am pretty stuck and not sure where the problem is. Hoping one of yall can help me figure out if this is a bug or not.


Hello @Jacob-Evans I haven’t looked at your code yet…but if you give all your endpoints -ID parameter names, you will be able to figure out which endpoint is causing the problem, instead of having the auto generated ID for the endpoint…then you can check the code in that…as that is your problem…

I already know what endpoint is causing the issue, i posted it directly below the error message.

The problem i am having is not knowing what endpoint is the problem, its the error message that follows the random generated ID that i am having a problem with.

hi @Jacob-Evans

The issue is that your get-details function is trying to create a new endpoint with the id " get-details" for each of your grid-rows.

Either remove the id-specifying, or use an unique ID for the endpoint.

Should solve your problems :slight_smile:

But that still occurs even if i only have 1 result in the grid, would that still be the cause?

Give it a go?

you might have another endpoint called get-details somewhere.

So i went ahead and removed the -id from Get-Details and it threw the same error. However when i look in the Diagnostics Page, i can see the the Get-Details looks like they ran:

Yet i still get the An item with the same key has already been added.

And i just searched my entire dashboard, no other endpoints with the ID get-details

Personally for this (from what i’m able to gather) i use the following:

New-UDbutton -text “show” -onclick {enter the endpoint code here } (the onclick should also be able to take a ud-endpoint instead of a scriptblock)

May be the “Show-UDModal” being called in the endpoint which is causing the issues, as it is not intended to be “onload”, but instead triggered by an event.

I’ll try to reverse engineer your code later and see if i can come to a solution,

Until then! :slight_smile:

Actually, what you just said made me realize that i wasn’t actually making a button, i was calling Get-Details and trying to execute the endpoint automatically, that is probably why it was failing, i wasn’t waiting for a button to be clicked.

1 Like

Glad to hear!

Keep me updated if the revised code works bro :slight_smile:

So i have updated my results element:

Set-UDElement -Id "results" -Content {
	New-UDGrid -Title "Search Results for: $accLookup" -Headers @("Username", "Name", "More Info", "Password Reset") -Properties @("Username", "Name", "MoreInfo", "ResetPW") -Endpoint {
		$Objects | ForEach-Object {
				Username = $_.UserPrincipalName
				Name     = $_.Name
				MoreInfo = New-UDButton -Text "Show Details" -OnClick (Get-Details $_)
				ResetPW  = $_.ResetPW
		} | Out-UDGridData

Now the kicker is that when you click the button, instead of showing the info for the user I wanted to show info on, it only shows the info from the last user in the list.

In that screenshot, i clicked on Test Student 22’s Show details button.

Sounds like an identical “ID” issue, are you using an unique ID on your endpoints?

Son of a… That did it… go figure, try to name my endpoints, it breaks. That will show me whose boss.

Time to come up with a new idea for it!

1 Like

Awesome dude!

If you need to name said endpoints either use an unique id from the grids data or just do
“-id (“Get-Details$(new-guid)”)”

With an prefix said endpoints should be easily identified :slight_smile:

$epid = $subject.Name + " Checking Out"

New-UDEndpoint -Id $epid -Endpoint

Is what i wound up going with.

1 Like