I’m seeing this very strange / intermitten case where when i check a box i get this error about not being able to index into an array.
I’m not sure how to troubleshoot it, but it happens when i attempt to exececute
$CheckboxValue = ((Get-UDElement -Id $($CheckboxID) -ErrorAction Stop).Attributes[“checked”])
The PUD log (in debug mode) shows:
17:08:15 [Info] Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker Executed action method UniversalDashboard.Controllers.ComponentController.SetElementSessionState (UniversalDashboard), returned result Microsoft.AspNetCore.Mvc.JsonResult in 0.3424ms.
17:08:15 [Info] Microsoft.AspNetCore.Mvc.Formatters.Json.Internal.JsonResultExecutor Executing JsonResult, writing value of type ‘<>f__AnonymousType2`1[[System.String, System.Private.CoreLib, Version=220.127.116.11, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]’.
17:08:15 [Info] Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker Executed action UniversalDashboard.Controllers.ComponentController.SetElementSessionState (UniversalDashboard) in 16.0438ms
17:08:15 [Info] Microsoft.AspNetCore.Hosting.Internal.WebHost Request finished in 30.6315ms 200 application/json; charset=utf-8
17:08:15 [Warn] PowerShellExecutionService Error executing endpoint 39e1a34c-2cf1-4f00-ab18-bc76b869b711. Cannot index into a null array.
at , : line 114
17:08:15 [Debug] PowerShellExecutionService ExecutionService constructor
17:08:15 [Debug] DashboardHub ClientEvent 39e1a34c-2cf1-4f00-ab18-bc76b869b711 onChange
17:08:15 [Debug] EndpointService Get() 39e1a34c-2cf1-4f00-ab18-bc76b869b711 87bcbba9-23fb-44c5-9ae6-7d09ea608ff6
17:08:15 [Debug] EndpointService Found session endpoint.
If it helps, the checkbox on change starts by creating an endpoint so i can pass some parameter data into it.
Essentially, my code looks like a more complex version of
https://docs.universaldashboard.io/components/checkbox the example at the bottom.
I create my checkbox similar, but I encapsulate the section starting after the “OnChange” in an endpoint and pass an object that I need to parse as an argument list.
I then before jumping out of the endpoint, I query the current checkbox state (so the example at the VERY bottom of the linked page), and then if the box is checked / not checked, i add / remove the object from a hash table.
Again, to reiterate the part that seems to be failing is the get-udendpoint. I’ve seen it fail in the checkbox, but also after the checkbox state has been updated / synced an I go back to query the state again.
I’m more than willing to upload my code, it’s way too much to try and block quote in here.
I’ve included a screen capture of the basic code (filtered out the logging commands i do)