PowerApps Clear Text Input

Task

Clear the Text Input field within a PowerApp.

Solution

Below are the below properties we are going to be editing with a description of what they each are.

Text Input
Default: The default value of the field, it accepts either a Text or Number value depending on its Format, which is another property with a pull down.
Reset: This property take a Boolean (true/false) value, it will “reset” the information displayed within the Text Input to its Default when set to True.

Screen
OnVisible: This runs when the screen launches.

Button
OnSelect: This runs when the button is selected/pressed.

Here is the TestScreen that we are working with today.
10-16-2018 3-31-37 PM

Setting the TextInput Properties

This will allow it to reset once the variable is set to true, setting the input back to whatever you have the Default set too.

  1. Select the TextInput
  2. Select Advanced
  3. Under DATA there is Default and Reset
    10-17-2018 8-11-28 AM
    Default: Set this to what you would like it to reset too, if you would like it to clear set it to “”.
    Reset: Set this to a Boolean (true/false) variable, I am using resetText.

Setting the Screen Properties

This flips the variable back and forth when the screen loads so that the field will always be cleared on load.

  1. Select the Screen, I am using TestScreen.
  2. Select the OnVisible Property
  3. Add below to the Property.
    10-17-2018 8-41-24 AM

    UpdateContext({resetText: true});
    UpdateContext({resetText: false})

Additional Uses

With the above code you can apply it also to a Clear Button as shown above. I personally also apply it to things like the back or cancel button to ensure it is cleared out before even leaving the screen. To do this just copy and paste the code into the OnSelect of the button or object you would like to perform this function.