You submit a form, store its data and now your form should reset to its inital state. So you need to reset the form. Resetting a PowerApps form is quite simple. The ResetForm function does all the hard work.
Nevertheless there are certain edge cases where it is getting a little tricky. To fully understand how to reset forms and individual form controls, you need to understand the following:
- ResetForm function
- OnReset property
- Reset function
- Reset property
- Clear property
We will address all of these in this article and will show in examples how to use them with different UI controls.
ResetForm Function
The ResetForm function does three things:
- Resets all form controls to their initial default value
- The code in under the OnReset property in the form is executed
- In case the Form mode is FormMode.New it is reset to FormMode.Edit
Syntax
ResetForm( FormName )
Input parameter
- FormName (mandatory): The form that needs to be reset.
Return value
- The ResetForm function does not return any value.
OnReset Property
As mentioned above, when you use the ResetForm function, the code in the OnReset property form gets executed. This way you are able to execute some code whenever a form is reset.
For instance you can do something like this:
Reset Function
The Reset function deletes the current value of an input control by setting the default value.
Syntax
Reset( Control )
Input parameter
- Control (mandatory): The control that needs to be reset.
Return value
- The Reset function does not return any value.
Reset Property
ResetForm does a reset for all form controls, but sometimes it makes sense to do a reset for some controls and not all. In this scenario the Reset property is helpful. You can decide on a group of controls that need to be reset. Just image you have big form and you just want to reset the address data within the form. But how can this be achieved?
Here is a simple example to demonstrate how to use the Reset Property.
Let’s image we are having three text inputs (Reset property exists on all input controls). Two test inputs have set their Reset property to a boolean variable called “doReset”.
Control | Default Value | Reset property |
---|---|---|
Text Input 1 | A | doReset |
Text Input 2 | B | doReset |
Text Input 3 | C | false |
In addition there is a button with the following OnSelect code:
Set(doReset,!doReset);
Set(doReset,!doReset); // needs to be done twice
This would look something like this:
Let’s enter some text in each text input:
And finally click the button. This will be the result:
As you can see, only the first two text input have been reset.
One question is left: Why do we need to call “Set(doReset,!doReset)” two times? It is because the reset is only triggered if the value is set to true. After the first click the value of doReset is true. A second click would set doReset to false. but would not reset the text input controls. By setting doReset twice the text inputs will be reset on every click.
Clear Property
The text input control has a clear property that can be turned on and off like via a property or a radio button:
The effect of enabling the clear property is that once a value is entered into the text input an X appears on the right of the control to clear the input. Note: The clear property clears the input, it does not reset the default value.
Turning the clear property on looks and behaves like this:
In this example the clear property is used to reset a search box to empty.
How To Reset Individual Form Controls By Example
Understand by simple examples how to reset a single form control.
Reset Text Input
Reset(MyTextInput)
How to Reset a PowerApps Text Input
We will do a simple example to demonstrate how to reset a text input. All you need is text input and a button to try it for yourself.
-
Create a text input called “MyTextInput”
-
Set a default value for your text input
Text Input – “MyTextInput” Default Value
-
Create a new button and set the “OnSelect” property to :
Text Input – “MyTextInput” Default Value
-
Start the application, enter some text in your text input and click your button. Your text input will reset to the defined default value.
Reset Drop down
To reset a single dropdown to its default value use the Reset function with the dropdown name as parameter.
Reset( MyDropdown)
How to Reset a PowerApps Dropdown
We will do a simple example to demonstrate how to reset a dropdown. All you need is a dropdown and a button to try it for yourself.
Step 1 Create a dropdown called “MyDropdown”
Step 2 Set a default value for your dropdown
Step 3 Create a new button and set the “OnSelect” property to :
Reset( MyDropdown)
Step 4 Start the application, try out different options of the dropdown and click your button. Your dropdown will reset to the defined default value.
Reset Combo Box
To reset a single combo box to its default value use the Reset function with the combo box name as parameter.
Reset( MyComboBox)
How to Reset a PowerApps Combo Box
We will do a simple example to demonstrate how to reset a combo box. All you need is a combo box button and a button to try it for yourself.
Step 1 Create a combo box called “MyComboBox”
Step 2 Set DefaultSelectedItems for your combo box
Step 3 Create a new button and set the “OnSelect” property to :
Reset( MyComboBox)
Step 4 Start the application, try out different options of the combo box and click your button. Your combo box will reset to the defined default value.
Reset Radio Button
To reset a single radio button to its default value use the Reset function with the radio button name as parameter.
Reset( MyRadio)
How to Reset a PowerApps Radio Button
We will do a simple example to demonstrate how to reset a radio button. All you need is a radio button and a button to try it for yourself.
Step 1 Create a radio button called “MyRadio”
Step 2 Set a default value for your radio button
Step 3 Create a new button and set the “OnSelect” property to :
Step 4 Start the application, try out different options in radio control and click your button. Your radio button will reset to the defined default value.
Reset Checkbox
To reset a single checkbox to its default value use the Reset function with the Checkbox name as parameter.
Reset(MyCheckbox)
How to Reset a PowerApps Checkbox
We will do a simple example to demonstrate how to reset a checkbox. All you need is a checkbox and a button to try it for yourself.
Step 1 Create a Checkbox called “MyCheckbox”
Step 2 Check that the default value is set to “Off” like shown below.
Step 3 Create a new button and set the “OnSelect” property to :
Reset(MyCheckbox)
Step 4 Start the application, check your checkbox and click your button. Your checkbox will reset to the default value “Off”.
Fantastic info here! Is there a way to just reset everything, all different controls, forms, etc, in one go? Or does it need built up and each section specified to clear?
Thanks!
ResetForm function resets a complete form.