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 / Issues with Text Input...
Power Apps
Unanswered

Issues with Text Input Reset property

(0) ShareShare
ReportReport
Posted on by 873

I cannot use forms because they are very rigid in layout.

I use a text input control linked to the source.

 

If I change the text of the text input and then have a button to save the change (i.e. a Patch operation), then if the change is not saved to the server (for example if a number is larger than allowed) then the text input resets back to the default ERASING any changes I made to the input, and it is not clear how to recover the new input.

 

The setting of the Reset property (i.e. True or False) does not seem to make any difference.  Could this be a bug?  If not, how is the Reset property meant to actually work?  In any case, how can I keep the changed text in case the patch operation does not go as expected?

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

    Hello - Could you please elaborate? Is it just a Text input and a button with the button formula being Patch(DataSource, SomeItem, ...)? 

     

    Thanks

    Murali

  • Brian Dang Profile Picture
    3,976 on at

    You will need to turn the Reset property true then false for it to go back to the Default value. Set the OnSelect property of whatever is triggering the Reset to:

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

     

    To keep the changed text in case it is not written, I would save the Patched record to a context variable with the existing Patch formula:

    UpdateContext({temprecord:
    
    Patch(datasource,Defaults(datasource),
    {column1: TextInput1.Text}
    )
    
    })

     

     

    Then if you want to recall the value that did not work, then set the Default property of the TextInput to:

    If(!IsEmpty(Errors(datasource)), temprecord.column1, "")

     

    This means "If there is an error, then make the default text the value you saved earlier. Otherwise, make it blank if Patching was successful."

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

    Wait. If the Patch is not successful, then I don't think the context variable will work. 

     

    I would just make a variable independent of the Patch:

    UpdateContext({temptext: TextInput1.Text});
    
    Patch(...)

    Then set the TextInput1.Default to:

    If(!IsEmpty(Errors(datasource)), temptext, "")
  • Steelman70 Profile Picture
    873 on at

    Hi Murali.  Yes, correct, it is just a text input and a button with the formula you suggest.  The need is to keep the new input even in case the patch is not successful.  The normal behaviour is to reset the text input to the default value, loosing any changes.  In any case I think Mr. Dang's idea is in the right direction, but it is a pity that we have to build extra code to deal with a normal situation.

  • Steelman70 Profile Picture
    873 on at

    Mr. Dang, thank you.  To smake it complete, I think the TextInput1.Default needs to be something like:

    If(IsEmpty(Errors(MySource)), MySource.MyField, temptext)

    This is so that the saved value is shown.

     

    Also, a useful trick is to make TextInput1.Color to be something like:

    If(TextInput1.Text=MySource.MyField, Black, Red)

    This is so that any unsaved data shows up as red.

  • murali Profile Picture
    on at

    Hello Steelman70 - I don't see that behavior though.

     

    Here is what I did:

     

    TextInput1: Text input

    Button1: Button with OnSelect = Patch(MyDataSource, Defaults(MyDataSource), {Title: TextInput1.Text})

     

    I typed some tet in TextInput1 and then I pressed the button. I let the request fail but the content remained on TextInput1.

    I used SharePoint datasource to repro this.

     

    However I could repro your issue with a Form control though. Is that what you meant?

     

    Thanks

    Murali

  • Steelman70 Profile Picture
    873 on at

    Hi Murali, thanks for following up.  Here is how you can reproduce the issue, and I just tried again with SharePoint Online.

     

    1. Create a list in SharePoint and add a column called Amount, and constrain the mininum amount as 0

    2. Create three random records with any values for Title and Amount

    3. Create a new PowerApp, place a gallery whose Items property is the list from SharePoint and display Title and Amount in two text boxes

    4. Create two TextInputs as follows:

    TextInputTitle.Default = Gallery1.Selected.Title
    TextInputAmount.Default = Gallery1.Selected.Amount

    5. Create a button as follows:

    Button1.OnSelect = Patch(MySPlist, Gallery1.Selected , {Title: TextInputTitle.Text, Amount: Value(TextInputAmount.Text)})

    Now, when you enter a positive number TextInputAmount, the value in SharePoint gets updated and all is fine.  When you place a negative value, however, the SharePoint list is not updated (i.e. the request fails) but the negative value disappears and is replaced with the original value.  This means that you lose your new input, and there is no way to recover it.

     

    Here is a screen shot just before pressing save...

     

    BeforeSave.JPG

     

     

     

     

     

     

     

     

     

     

     

     

     

    ..and here just after pressing the save button...

    AfterSave.JPG

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 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard