Setting parameter based on form input

Hello,

Would anyone know how to setup a simple textbox and have that be the parameter for a script. I have written it like this but it keeps returning an empty string.

New-UDTextbox -Id “input”

New-UDButton -Text 'Job' -OnClick {

    Invoke-UAScript -Name 'test.ps1' -testparam $eventdata.input  

}

Thank you!

Product: PowerShell Universal
Version: 1.4.6

Try doing

Show-UDToast -Message "$EventData" -Duration 10000 

for the OnClick action, just to see what you are getting. This will return the object for you to see in the top right corner of your screen. Very useful for debugging to see what is contained in the variable.
I have something similar on my dashboard but in a UDStepper for techs to complete.

Sorry I should’ve said in the jobs report I can see it ran but I get the following error. A UDToast returns blank.

Sep 13, 2021 1:43 PM [error] Cannot bind argument to parameter ‘testparam’ because it is an empty string.

Try doing this:

$myInput = (Get-UDElement -Id 'input').value 
Invoke-UAScript -Name 'test.ps1' -testparam $myInput

No dice.

Sep 13, 2021 2:32 PM [error] Cannot bind argument to parameter ‘testparam’ because it is an empty string.

He’s the whole snippet

New-UDTextbox -Id "input"
$myInput = (Get-UDElement -Id 'input').value
New-UDButton -Text 'Job' -OnClick {
    Invoke-UAScript -Name 'wmitest.ps1' -InvGateTicket $myInput
}

Try reading the value in the button click.

New-UDTextbox -Id "input"

New-UDButton -Text 'Job' -OnClick {
    $myInput = (Get-UDElement -Id 'input').value
    Invoke-UAScript -Name 'wmitest.ps1' -InvGateTicket $myInput
}

I don’t think it matters, but for chuckles, try this:

New-UDForm -Content {
      New-UDTextbox -Id "input"
} -OnSubmit {
    $myInput = $($EventData.Input)
    Invoke-UAScript -Name 'wmitest.ps1' -InvGateTicket $myInput
}

This needs to happen in the OnClick, not before I believe.

That worked Adam, thank you!