web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / How to clear a Text Input
Power Apps
Answered

How to clear a Text Input

(1) ShareShare
ReportReport
Posted on by 135

Hi to all

 

I have this situatión, I have two screen, in the first one I have a text input in order the user type the name,one the user click the next button I filtered the information in the second screen, everything looks ok, the problem is when I return to the first screen I continue seeing the name of the user, how can I clear that information 

 

Thank you

Categories:
I have the same question (0)
  • hngdev Profile Picture
    304 on at

    What you can try this: 

    • OnVisible of Screen called Screen1 that contains TextInput controller: UpdateContext({filter: Left(filter,0)}) 
    • Default property of TextInput controller: filter
    • When navigate to other screens: Navigate(Screen2, Cover, {filter:TextInput.Text})
    • OnSelect on Button that navigates back to the first screen: Navigate(Screen1, ScreenTransition.Cover, {filter: " "}) //There should be a space between quotes

    It should work.

  • Brian Dang Profile Picture
    3,976 on at

    Here's another way I learned from the templates.

     

    Set the TextInput.Reset property to:

    Button1.Pressed

    Whenever the button is pressed, that will reset the TextInput.Text to whatever the default is--which, in your case, is "".

  • Jamarchi Profile Picture
    135 on at

    Hi and thank you to both of you for the answers

     

    I tested both suggestion and both worked fine but has a problem, when I clicl the button the information in the text input is erased and it can“t be sent to the second screen

     

    Thank you

  • hngdev Profile Picture
    304 on at

    The way I approach is that I use a variable (filter) to store the text input data, when you click the button the Navigate function would wrap the filter variable and sent to the other screen. On the destination screen, you can use filter variable to get data.

  • Jamarchi Profile Picture
    135 on at

    Hi

     

    But how and when do you store the value in a variable?

  • hngdev Profile Picture
    304 on at

    You can have a check over on my answer above.

    I initialize the variable in Screen1's OnVisible

    Then, assign the variable to the text input.

    Then, wrap the variable storing text input data and navigate to Screen2

    On Screen2, you can use the variable.

  • Verified answer
    Brian Dang Profile Picture
    3,976 on at

    Ok, I see my error. Forget my first suggestion. That only works if you don't need that value in the textbox after typing it--i.e. clearing the username after someone clicks a button to login.

     

    You can go with hngdev's suggestion if you want to carry the filtered table in a variable.

     

    If you want to keep most things as they are, then you can try this:

     

    Set Screen1.OnVisible to:

    UpdateContext({resettext: !resettext});
    UpdateContext({resettext: !resettext})

    Set TextInput1.Reset to:

    resettext

    Set TextInput1.Default to:

    ""

     

    Keep your filtered table the same.

     

    This is how it works. Any time that you go to Screen1, the OnVisible actions will trigger. So it toggles the "resettext" variable to true, then back to false. The TextInput box will detect the change in the Reset property and reset the text to the Default value, which we set to "", which is blank.

     

    If you navigate away from Screen1, the value in TextInput1 will stay the same. It will only reset when you go to Screen1.

  • hpkeong Profile Picture
    2,944 on at

    Hi

     

    Option1:

     

    Dang's suggestion is correct. Maybe the way it is triggered.

    1. You enter Name (in screen 1) in TextInput1; set the Reset: Button2.Pressed

    2. Click a button1 and navigate to Screen 2 (Button1, OnSelect: Navigate(Screen2, None))

    3. Click a button2 and navigate back to Screen 1; (Button2: OnSelect: Navigate(Screen1, None))

    4. In Screen1, you will see that TextInput1 entry is now cleared.

     

    Reset: this can be triggered from another screen (global).

    NB: When you click on Screen2 Button, the TextInput1 is cleared even before you navigate back to screen1.

     

    Option 2:

     

    You may also use UpdateContext, but this is local to the screen. 

    NB: When you click on Screen2 Button, the TextInput1 is cleared ONLY when you are in screen1 (you can see the test is cleared just when you navigate into screen1).

     

     

    1.  Insert a TextInput1 (in screen 1);

    - under Default, say you name it: Default: MyText

    - under OnVisible (Screen1), enter: OnVisible: UpdateContext({MyText: " "}); UpdateContext({MyText: ""}).

    2. You enter Name (in screen 1) in TextInput1.

    3. Click a button1 and navigate to Screen 2 (Button1, OnSelect: Navigate(Screen2, None))

    4. Click a button2 and navigate back to Screen 1; (Button2: OnSelect: Navigate(Screen1, None))

    5. In Screen1, you will see that TextInput1 entry is now cleared.

     

    Always take note:

    UpdateContext({MyText: " "}); UpdateContext({MyText: ""}).

    " " - first one with space; "": second one with space.

    Otherwise, you will never get your result.

     

    They are numerous discussion over this with a lot of different options in Project Siena forum. https://social.technet.microsoft.com/Forums/en-US/de063751-7baa-41f0-af8d-20eb05126e40/how-do-i-clear-or-change-the-text-typed-into-a-text-box?forum=projectsiena

     

    Hoe this supplements the rests and helps.

  • Jamarchi Profile Picture
    135 on at

    Hi

     

    Thank you very much for your help, finally It works, I followed the Dang's suggestion and now works as I espected

     

    Thank you

  • Community Power Platform Member Profile Picture
    on at

    I have utilized the "Reset.Pressed" method to clear fields in text, dropdown, radio, toggle, and date picker field types.  This works great when playing it from the studio, however, when I upload it to the cloud and use it on a tablet, the fields do not reset.  Has anyone else experienced this issue and/or has anyone else found a way to resolve it?

     


    @hpkeong wrote:

    Hi

     

    Option1:

     

    Dang's suggestion is correct. Maybe the way it is triggered.

    1. You enter Name (in screen 1) in TextInput1; set the Reset: Button2.Pressed

    2. Click a button1 and navigate to Screen 2 (Button1, OnSelect: Navigate(Screen2, None))

    3. Click a button2 and navigate back to Screen 1; (Button2: OnSelect: Navigate(Screen1, None))

    4. In Screen1, you will see that TextInput1 entry is now cleared.

     

    Reset: this can be triggered from another screen (global).

    NB: When you click on Screen2 Button, the TextInput1 is cleared even before you navigate back to screen1.

     

    Option 2:

     

    You may also use UpdateContext, but this is local to the screen. 

    NB: When you click on Screen2 Button, the TextInput1 is cleared ONLY when you are in screen1 (you can see the test is cleared just when you navigate into screen1).

     

     

    1.  Insert a TextInput1 (in screen 1);

    - under Default, say you name it: Default: MyText

    - under OnVisible (Screen1), enter: OnVisible: UpdateContext({MyText: " "}); UpdateContext({MyText: ""}).

    2. You enter Name (in screen 1) in TextInput1.

    3. Click a button1 and navigate to Screen 2 (Button1, OnSelect: Navigate(Screen2, None))

    4. Click a button2 and navigate back to Screen 1; (Button2: OnSelect: Navigate(Screen1, None))

    5. In Screen1, you will see that TextInput1 entry is now cleared.

     

    Always take note:

    UpdateContext({MyText: " "}); UpdateContext({MyText: ""}).

    " " - first one with space; "": second one with space.

    Otherwise, you will never get your result.

     

    They are numerous discussion over this with a lot of different options in Project Siena forum. https://social.technet.microsoft.com/Forums/en-US/de063751-7baa-41f0-af8d-20eb05126e40/how-do-i-clear-or-change-the-text-typed-into-a-text-box?forum=projectsiena

     

    Hoe this supplements the rests and helps.


     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 721 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 320 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard