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 / Best practice to reset...
Power Apps
Unanswered

Best practice to reset custom form fields

(1) ShareShare
ReportReport
Posted on by 41
Hello, I am working on a canvas app and I am using a container to create a form in a specific design for users. I am using the patch function with some validation on the input fields. However, I can easily patch the data back to SharePoint, but what I can't seem to find online is an efficient way to reset the fields when a users has submitted the form. Right now, my button to submit has a displaymode to make sure all inputs have met their validations and once they have the displaymode becomes "edit'. I then patch the data back to SharePoint, but after that where do I reset my controls? Is there a proper way to do it after the data has successfully patched to SharePoint? 
Categories:
I have the same question (0)
  • Suggested answer
    tsa-svd2srv Profile Picture
    204 on at
    Assuming it's some sort of "Submit" butt that contains the Patch function, please provide the code from your OnSelect property.
     
    Off the top of my head, I think your going to need something like:
    YourCurrentCode(
    .
    .
    .
    );
    Reset(ControlName1);
    Reset(ControlName2);
    Reset(ControlName3);
    Reset(ControlName4);
    Reset(ControlName5);
    
    and so on.
     
    Let me know if it works.
     
  • Suggested answer
    timl Profile Picture
    36,383 Super User 2025 Season 2 on at
     
    The ResetForm function will reset all controls on a form back to their initial values. Perhaps that might help you?
     
    ResetForm(YourForm)
      
     
  • Verified answer
    Signstech Profile Picture
    7 on at
    You have two good answers as replies.   To take each a step further for both replies...
     
    • As @ElvirBotic response provided...if you are using a 'FORM', then you can add the 'ResetForm' formula to the OnSelect property, after the Patch.
      • Example(s)
        • OPTION 1
    // OnSelect property of your Submit Button
    Patch(SharePointList, Defaults(SharePointList), YourFormName.Item);
    ResetForm(YourFormName)
    • OPTION 2
    //OnSuccess property of your Form
    ResetForm(YourFormName)
    * NOTE: If a failure occurs during the save, you don't want the form to reset, clearing out the data in the fields.  To avoid this, you should place the ResetForm formula inside the //OnSuccess property of your Form and not within the OnSelect property.
     
    • Agree with @tsa-svd2srv response.  If you are not using any form, but you have a bunch of TextInput fields within a container to look like a custom form, then yes, you will have to add each field to the to the OnSelect property after the Patch.
    // OnSelect property of your Submit Button
    Patch(SharePointList, Defaults(SharePointList), {
    Title: TextInput.Text,
    Description: DescriptionInput.Text,
    // Add other fields here
    });
    
    // Reset each control
    Reset(TextInput);
    Reset(DescriptionInput);
    // Add the rest of you Reset functions for all other input controls
  • timl Profile Picture
    36,383 Super User 2025 Season 2 on at
     
    @ElvirBotic is Patching the data to SharePoint, therefore OnSuccess is not applicable because this only applies when calling SubmitForm.
     
    Also, the Updates property of the form returns all updated fields on a form. The form control does not expose a property called Item.
     
    The correct approach error checking is to call IfError like so.
     
    IfError(
        Patch(SharePointList, Defaults(SharePointList), YourFormName.Updates),
        Notify("An error occurred while saving the record.", NotificationType.Error),
        ResetForm(YourFormName)
    )
     

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