ryan.d  
                
               
                 
              
                  
                    September 13, 2021,  5:47pm
                   
                   
              1 
               
             
            
              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
 
             
            
               
               
               
            
            
           
          
            
              
                Mike27  
                
               
              
                  
                    September 13, 2021,  6:22pm
                   
                   
              2 
               
             
            
              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.
             
            
               
               
               
            
            
           
          
            
              
                ryan.d  
                
               
              
                  
                    September 13, 2021,  6:26pm
                   
                   
              3 
               
             
            
              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.
 
             
            
               
               
               
            
            
           
          
            
              
                Mike27  
                
               
              
                  
                    September 13, 2021,  6:28pm
                   
                   
              4 
               
             
            
              Try doing this:
$myInput = (Get-UDElement -Id 'input').value 
Invoke-UAScript -Name 'test.ps1' -testparam $myInput
 
             
            
               
               
               
            
            
           
          
            
              
                adam  
                
               
              
                  
                    September 13, 2021,  6:36pm
                   
                   
              7 
               
             
            
              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
}
 
             
            
               
               
               
            
            
           
          
            
              
                Mike27  
                
               
              
                  
                    September 13, 2021,  6:38pm
                   
                   
              8 
               
             
            
              
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
}
 
             
            
               
               
               
            
            
           
          
            
              
                Mike27  
                
               
              
                  
                    September 13, 2021,  6:39pm
                   
                   
              9 
               
             
            
              
This needs to happen in the OnClick, not before I believe.
             
            
               
               
               
            
            
           
          
            
              
                ryan.d  
                
               
              
                  
                    September 13, 2021,  6:46pm
                   
                   
              10 
               
             
            
              That worked Adam, thank you!