New-UDInput validation is not working before submit

Up to version 2.7.0 whenever you use validation with new-udinput, the moment you click on the second box the green circle will spin and do the validate and provide the error message as expected.

recently with nightly builds the green circle will spin and nothing like what you have entered is valid, then when you click submit you get the validation error.

based on my testing the issue is in the client folder cause when i replace client folder with an older version or with the current one from 2.7.0 it works again.

here is a sample

Get-UDDashboard | Stop-UDDashboard 

Start-UDDashboard -Dashboard (
    New-UDDashboard -Title "Test" -Content {

    New-UDInput -Title 'Restore Staging DBs' -SubmitText 'Continue' -Content {

    New-UDInputField -Type 'textbox' -Name 'UserName' -Placeholder 'User Name'
    New-UDInputField -Type 'password' -Name 'password' -Placeholder 'Password'
    

    } -Endpoint {


        param(
            [Parameter(Mandatory = $True)]
            [UniversalDashboard.ValidationErrorMessage("UserName is inavalid or you don't have rights, please check!")]
            [ValidateScript( {

                    $Members = Get-ADGroupMember -Identity 'Test' -Recursive | Select -ExpandProperty SamAccountName

                    if ($Members -contains $_) {

                        $True 
                        $Session:U = $_
                    }
                    else { Throw "error" }

                })]

            $UserName,

            [Parameter(Mandatory = $True)]
            [UniversalDashboard.ValidationErrorMessage("Password is inavalid, please check!")]
            [ValidateScript( {
                    Add-Type -AssemblyName System.DirectoryServices.AccountManagement
                    $obj = New-Object System.DirectoryServices.AccountManagement.PrincipalContext('domain', 'lms.local')
                    if (($obj.ValidateCredentials($Session:U, $_)) -eq $True) {

                        $True 
                    }
                    else { Throw "error" }

                })]

            $Password
            )

            } -Validate
            }
                

) -Port 80 -wait

Found the corrupted file its fetch-service.jsx under this path : .\src\client\src\app\services

it has been updated 23 days ago based on Fixes ironmansoftware#1301

the following line : var jsonresponse = response.json; needs to be var jsonresponse = response.json();

in fetch-service.jsx

Sorry, my bad :open_mouth:
PR in:

Should be in a nightly build soonish.

Kudos for the awesome debugging tho! @wsl2001

Thank you , Oh by the way your new Added invoke-udelement with documentation, fixes #616 #1349

you are calling the function new-udevent but you .MD file example call it invoke-udelement is ilooks like its a mismatch.

Ahem… yeah… the cat ran over the keyboard ?
Damn, I’ve got some typos :-o gutta stop rushing PRs while at work :sweat_smile:
Thanks for your QA services my dude :slight_smile:

2 Likes

Using Get-UDElement throws clientside js error:
“SyntaxError: Unexpected end of JSON input
at fetch-service.jsx:50”

the issue still there as before even after the fix, ther error message still appears on my chrome browser.