Reset function in Power Apps
The Reset function in Power Apps is used to reset the value of one or more controls on a screen to their default value. When a user interacts with a screen and modifies the value of one or more controls, the Reset function can be used to revert those changes and restore the original default values.
We cannot reset controls that are within a Gallery or Edit form control from outside those controls. We can reset controls from formulas on controls within the same gallery or form. We can also reset all the controls within a form with the ResetForm function.
Power Apps Syntax Reset(Name_of_the_Control ) • Name_of_the_Control – Required. The control to reset. Example: This example uses the Reset function to reset the controls. Step 1: Insert a Text input control on a screen. By default, its name will be TextInput1 and its Default property will be set to "Text input".
Step 2: Type a new value in the text box.
Step 3: Insert a Button control on the screen. Step 4: Set the button's OnSelect property to Reset(TextInput1).
Step 5: In the app preview mode. Select the button.
Step 6: The contents of the text box will return to the value of the Default property value i.e., “Text input”.
Alternative approach to Reset the controls without using Reset function
The Reset function is an alternative to toggling the Reset property of input controls and is generally preferred. The Reset property may be a better choice if there are many controls need to be reset together. Because in that case we need to write Reset function for each control.
a. Reset control on button pressed
The controls can be reset by using the Reset property. The Reset Property can be toggled by using the button control.
Step 1: Select the control or controls that we want to Reset.
Step 2: Set the selected controls Reset property to the following formula
Power Apps Formula
Here, Button1 is the name of the button control. While the button is pressed the above formula returns true then again false. It is required for the controls, to create an environment to reset the controls again.
b. Reset control by using variable
The Reset property of a control can be toggled by using a variable.
Step 1: Select the control or controls that we want to Reset.
Step 2: Set their Reset property to a variable myvar.
Step 3: We can toggle the variable myvar by the following formula on the OnSelect property of a button control.
Power Apps Formula
Step 4: Put the app preview mode and test the app.