How To Reset Forms And Form Controls In PowerApps

PowerApps Reset Forms

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:

Example of how to use OnRest property

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”.

ControlDefault ValueReset property
Text Input 1AdoReset
Text Input 2BdoReset
Text Input 3Cfalse

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:

Clear Property on text input
Clear Property 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:

Clear property in action

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.

  1. Create a text input called “MyTextInput”

  2. Set a default value for your text input

    powerapps reset textinput default value

    Text Input – “MyTextInput” Default Value

  3. Create a new button and set the “OnSelect” property to :

    powerapps reset textinput reset

    Text Input – “MyTextInput” Default Value

  4. 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

“MyDropdown” with default value set

Step 3 Create a new button and set the “OnSelect” property to :

Reset( MyDropdown)
Button to trigger Dropdown Reset function

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

“MyComboBox” with DefaultSelectedItems defined

Step 3 Create a new button and set the “OnSelect” property to :

Reset( MyComboBox)
Button to trigger Combobox Reset function

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

“MyRadio” Radio button with default “default”

Step 3 Create a new button and set the “OnSelect” property to :

Button to trigger Radio Reset function

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.

MyCheckbox with default to “Off”

Step 3 Create a new button and set the “OnSelect” property to :

Reset(MyCheckbox)
Button to trigger Checkbox Reset function

Step 4 Start the application, check your checkbox and click your button. Your checkbox will reset to the default value “Off”.

Leave a Comment

Your email address will not be published.