cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
tbrantley
Level: Powered On

How to clear text input fields?

How can you clear text input fields after you submit the data? After I press submit it reloads the same page with values in the text boxes.

 

Capture1.PNG

2 ACCEPTED SOLUTIONS

Accepted Solutions
MelindaK
Level 8

Re: How to clear text input fields?

@tbrantley

 

In your case you will need to use a different variable for each text box you have.

So for the ones you have screenshot you will have defaultClock and defaultAddress (for example). They will be set on the OnChange property of the DriverName drop down. So your OnChange will change to:

UpdateContext({Driver: LookUp(DriverInfo, Dropdown8.Selected.Name exactin Name), defaultClock: Driver.Clock, defaultAddress: Driver.Address})

And then the Default property on the text boxes will be defaultClock for the Clock text box and defaultAddress for the Address text box.

 

Then on the Save button you will only add:

UpdateContext({defaultClock:"", defaultAddress: ""})

- they will then change to the coresponding ones when the driver is selected from the drop down.

You don't need to set any OnVisible property of the screen.

 

Hope this makes more sense 🙂 

 

 

MelindaK

View solution in original post

MelindaK
Level 8

Re: How to clear text input fields?

@tbrantley

 

On drop down you should use the Reset property to reset their values. So instead of assigning a variable to the Default property, set the Reset property to be buttonName.Pressed - where buttonName is the name of your 'New Entry' button.

 

Hope this helps 🙂 

MelindaK

View solution in original post

9 REPLIES 9
alexdec
Level: Powered On

Re: How to clear text input fields?

I have the same problem with a drop down menu. The option for reset is "true" and I put a default value. However, if I select an item in the box, I validate the form then I come back on the page, I still have the same item selected in the drop down menu.

Can someone from Microsoft give a solution or correct the issue ?

MelindaK
Level 8

Re: How to clear text input fields?

Hi @tbrantley,

 

In order to clear the text boxes you need to use context variables.

You will need to set your Default property of the TextBox to be a variable, for example resetControls. Then on the OnSelect propert of the submit button add the UpdateContext({resetControls: ""}) after the submit function.

 

Or you can set the OnVisible property of the page to be UpdateContext({resetControls: ""}) - this will reset the controls everytime that page is made visible.

 

Hope this helps 🙂 

MelindaK
Highlighted
tbrantley
Level: Powered On

Re: How to clear text input fields?

@MelindaK

 

How would this work if I'm already setting a value in the default property?

 

Capture2.PNG

MelindaK
Level 8

Re: How to clear text input fields?

@tbrantley

 

Well if you want to put the default value back in the text box instead of the value that has been input by the user then on the OnSubmit property, after the Submit function, change the UpdateContext to UpdateContext({resetControls: Driver.Clock}).

 

You will still use the resetControls as the value of the Default propert, and will set it on the OnVisible property of the screen using UpdateContext({resetControls: Driver.Clock}) - so that it will be set before you submit the form.

 

 

MelindaK
tbrantley
Level: Powered On

Re: How to clear text input fields?

@MelindaK

 

I'm still a little confused. This give you a better idea of what my app is doing

 

Capture3.PNGCapture4.PNGCapture5.PNG

MelindaK
Level 8

Re: How to clear text input fields?

@tbrantley

 

In your case you will need to use a different variable for each text box you have.

So for the ones you have screenshot you will have defaultClock and defaultAddress (for example). They will be set on the OnChange property of the DriverName drop down. So your OnChange will change to:

UpdateContext({Driver: LookUp(DriverInfo, Dropdown8.Selected.Name exactin Name), defaultClock: Driver.Clock, defaultAddress: Driver.Address})

And then the Default property on the text boxes will be defaultClock for the Clock text box and defaultAddress for the Address text box.

 

Then on the Save button you will only add:

UpdateContext({defaultClock:"", defaultAddress: ""})

- they will then change to the coresponding ones when the driver is selected from the drop down.

You don't need to set any OnVisible property of the screen.

 

Hope this makes more sense 🙂 

 

 

MelindaK

View solution in original post

tbrantley
Level: Powered On

Re: How to clear text input fields?

@MelindaK

 

Hey I'm trying to make the default value of these drop down boxes "00" when "New Entry" is clicked. For some reason it doesn't clear them after the first click but clears the drop downs after the second click. Can anyone help?

 

New Entry OnSelect property

Capture6.PNG

 

 

DropDown3 default property

Capture7.PNG

MelindaK
Level 8

Re: How to clear text input fields?

@tbrantley

 

On drop down you should use the Reset property to reset their values. So instead of assigning a variable to the Default property, set the Reset property to be buttonName.Pressed - where buttonName is the name of your 'New Entry' button.

 

Hope this helps 🙂 

MelindaK

View solution in original post

Anonymous
Not applicable

Re: How to clear text input fields?

@alexdec Were you able to accomplish this? Currently stucked in this step. Sounded so simple yet... 😞 OY!

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors (Last 30 Days)
Users online (6,349)