UDButton clientEvent onClick not found

@adam

I am getting the following error for all my UDButtons using the parameter -ArgumentList

An unexpected error occurred invoking 'clientEvent' on the server. Exception: Endpoint 36308dac-ada4-4ce9-a74e-4c12befdfbb8onClick not found.

$MyVariable = "Some Text"
New-UDButton -Text "Click me!" -OnClick (
    New-UDEndpoint -Endpoint {
        Show-UDToast -Message $ArgumentList[0]
    } -ArgumentList @($MyVariable)
)

this example is coming directly from the UD doc -https://docs.universaldashboard.io/components/button#passing-variables-to-a-button-onclick-handler

I already tried to spot any local issues on my machine by clearing the browser cache, restarting my computer and installing the latest nightly build, but its still not working.

Am I doing something wrong or has the logic to pass variables into a button click event changed in v3?

If the logic has changed can you please provide me a working example and add this to the v3 doc ()?

This should work the same. Likely a bug.

I will open an issue … would be great to resolve this one soon as it is a core feature … :+1:

Agreed. Quite strange since there is a passing integration test for this. It’s likely the endpoint is becoming unregistered some how.

Can you replicate this on your machine?

I haven’t tried yet but I’m sure I’ll be able to. We have tests that validate this functionality but they probably are missing something.

1 Like

The hosted version is having this problem: https://universaldashboard-dev.azurewebsites.net/button

@adam

still having this problem with beta2 :confused:

$MyVariable = "Some Text"
    New-UDButton -Text "Click me!" -OnClick (
        New-UDEndpoint -Endpoint {
            Show-UDToast -Message $ArgumentList[0]
        } -ArgumentList @($MyVariable)
    )

I have tested the following:

Hmmm. I feel like I’m going crazy. That syntax doesn’t work for me either now. That said, this syntax does work.

    $MyVariable = "Some Text"
    New-UDButton -Text "Click me!" -OnClick {
        Show-UDToast -Message $MyVariable
    }

Your code (not using the UDEndpoint) is working for me too but not if I am using it in combination with a function and a UDTable. This will not pass the required variables into the function.

Here is a sample code that points out what my problem is:

PS: ignore the first error “cannot find cmdlet” … dont know why this is happening but is not part of this problem.

function New-UDNewTestButton
    {
        param 
        (
            [Parameter (Mandatory = $true, ParameterSetName = "Default")]
            [string]$Text
        )

        New-UDButton -Text "NotWorking" -OnClick { 
            Show-UDToast -Message $Text 
        } 
    }

    $Columns = @(
        New-UDTableColumn -Property ID1 -Title Button_Working -Render { 
            New-UDButton -Text "Working" -OnClick { 
                Show-UDToast -Message $Body 
            }
        }

        New-UDTableColumn -Property ID2 -Title Button_NotWorking -Render { 
             New-UDNewTestButton -Text $Body
        }
        New-UDTableColumn -Property Name -Title Name 
        New-UDTableColumn -Property Description -Title Description
    )

    #$Data = @(Get-ADWDWObjectType | Select ID, Name, Description) 
    $Data = ConvertFrom-Json '[{"Name":"test","Description":"testing","ID":"1c229a64-d499-4d91-9102-829412efb6b0"},{"Name":"Auto","Description":null,"ID":"52103d0b-3144-4fe3-aa94-e3f986926e7c"},{"Name":"Person","Description":null,"ID":"72ae0e64-c35c-4a0a-aad1-39e056c51d48"},{"Name":"Person2","Description":null,"ID":"9a166c5b-0ddf-4759-84b0-b7c15c4d59bd"}]'

    New-UDTable -Data $Data -Columns $Columns

The “WORKING” button is returning the body but the “NOTWORKING” button not as this one is creating the UDButton not in the same context or something like this (inside an external function)

Thanks for the full script. That’s helpful.

1 Like

@adam any update?

@adam this one is stopping me from having any progress on my project using UD, as a button is a key feature for am admin dashboard … :slight_smile: would be great to get this fixed soon.

@augustin.ziegler - I’m looking into it. There is a bug that will need to be fixed.

Great, if you need some help from my side just let me know.

e.g. if you fixed something and I need to validate this, just create a new release and I will test it

Thanks

PR is here: https://github.com/ironmansoftware/universal-dashboard/pull/1615

Great, I can test it as soon as it is in the nightly release :slight_smile:

@adam FYI the PR is not applied… please add it to ensure its included into the nightly build :slight_smile: