Reset Form after button click

My form is working like it should thanks to the folks on this forum. I have another issue I’m struggling with. How do I get the form to reset after the user hits the submit button? I currenlty have to exit out of the form for the script to end.

#region gui events { $btn1.Add_Click({ sendRequest; thankyou }) #endregion events } #endregion GUI } function sendRequest() { # API Key $FDApiKey="api key" ################################################# # Force TLS1.2 as Powershell defaults to TLS 1.0 and Freshdesk will fail connections [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::TLS12 # Prep $pair = "$($FDApiKey):$($FDApiKey)" $bytes = [System.Text.Encoding]::ASCII.GetBytes($pair) $base64 = [System.Convert]::ToBase64String($bytes) $basicAuthValue = "Basic $base64" $FDHeaders = @{ Authorization = $basicAuthValue } ################################################## $Body = @{ description = $description.Text email = $email.Text subject = $subject.Text type = $request.Text priority = 1 status = 2 } Invoke-WebRequest "https://clasd.freshdesk.com/api/v2/tickets/" -Headers $FDHeaders - ContentType "application/json" -Method Post -Body ($Body | ConvertTo-JSON) } function thankyou () { [System.Windows.Forms.MessageBox]::Show("Your ticket has been submitted!" , "Status") } #Write your logic code here [void]$Form.ShowDialog() 

submitted by /u/Wizard210
[link] [comments]

Leave a Reply