cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
PowerAppsHori
Helper I
Helper I

So Confused. How Do I Reset Form After Adding Patch to Submit Button?

I’ve been tasked with updating a SharePoint 2013 ticket system that’s a combo of InfoPath, Workflows and SharePoint. However, it feels like PowerApps fights me at every turn. Here’s how the form currently works (and how I’d like it to still work):

 

1) A user goes to a form and from a drop down selects 1 of 15 Contracts

2) Once one is selected, the form will show fields specific to that Contract type that need to be filled out

3) Once the user fills out the fields, they submit the form

4) The information is sent to a SharePoint list

5) The Contracts team is notified of the new item, they go into SharePoint and look at the details

6) There’s a comment system where folks communicate back and forth

7) Eventually the Contracts team processes the request then marks the item as complete in SharePoint

7) Everyone gets a notification that the item has been completed

 

In InfoPath I can basically stack forms together and show/hide based on selections. PowerApps can do that too but not easily. It seems that PowerApps REALLY wants me to use only one form in the app. However, it’s impossible to design the fields in one app because everything locks and shifts because the canvas is column based (I’ve turned snap off and that barely helps). Each Contract type has different fields that need to be filled out, so I have about 80 columns/input fields across 15 choices that I gotta put in there. So I figured I’d add multiple forms or screens. However, when I submit the form with multiple forms or screens, only the original form seems to submit. I looked everywhere for an answer and it seems I gotta patch submit the forms. But when I do that the forms don’t reset although it now submits correctly. 

 

I’m kind of pulling my hair out and just need someone to help me figure out the best way to build this app. At this point I’m hoping someone can help me figure out how to reset the form after I press the submit button that patches the info to SharePoint (or if you have another solution). Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
timl
Super User
Super User

Hi @PowerAppsHori 

A quick way to reset a form would be to call the NewForm function for all your forms after your call to Patch.

NewForm(EditForm1);
NewForm(EditForm2)

 This would setup your forms to accept the entry of a new record but in essense, it'll clear the previous entries.

View solution in original post

6 REPLIES 6
timl
Super User
Super User

Hi @PowerAppsHori 

A quick way to reset a form would be to call the NewForm function for all your forms after your call to Patch.

NewForm(EditForm1);
NewForm(EditForm2)

 This would setup your forms to accept the entry of a new record but in essense, it'll clear the previous entries.

View solution in original post

v-xida-msft
Community Support
Community Support

Hi @PowerAppsHori ,

Yeah, you are right. If you use Patch function to submit your form data, the Edit form would not be reset automatically when the PATCH function executes successfully (it's a normal behavior).

 

As an fixed solution, you need to add the RestForm() function after your PATCH formula to reset your Edit form. I have made a test on my side, please try the following workaround:

Set the OnSelect property of the "Submit" button to following:

 

Patch(
      'Your SP List',
      Defaults('Your SP List'),
      EditForm1.Updates,
      EditForm2.Updates,
      ...
);
ResetForm(EditForm1);    // Add this formula after your Patch formula to reset Edit form
ResetForm(EditForm2);
...

 

Set the DefaultMode property of the EditForm1, EditForm2, EditFrom3, .... to following:

 

FormMode.New

 

Note: The EditForm1, EditForm2, EditForm3, ... represents the Edit form in your canvas app

 

Please consider take a try with above solution, then check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @PowerAppsHori 

Just to elaborate a bit further on this, the ResetForm function as @v-xida-msft  suggests will also work. That is to call the following code, and to set the DefaultMode property on all your forms.

 

 

Patch(
      'Your SP List',
      Defaults('Your SP List'),
      EditForm1.Updates,
      EditForm2.Updates,
      ...
);
ResetForm(EditForm1);    // Add this formula after your Patch formula to reset Edit form
ResetForm(EditForm2);
...

 

-------------------

If you were to call the NewForm function as I mentioned in my first post, this will place the form in 'new mode'.

 

 

Patch(
      'Your SP List',
      Defaults('Your SP List'),
      EditForm1.Updates,
      EditForm2.Updates,
      ...
);
NewForm(EditForm1);    // Add this formula after your Patch formula to reset Edit form
NewForm(EditForm2);
...

 

 

Therefore, this saves you the extra task of setting the DefaultMode property on all your forms, which can save you some time.

Hopefully, one of these options will work for you. If not, let us know.

 

@timl that is helpful and it solved my issue partially. However my new form still continued to come up with some undesired default values. I then figured out that clearing any collection used in drop-downs on the form, and an additional ResetForm was required to get it right, e.g. in the OnSuccess Event of the form

Clear(collection1); Clear(collection2); ResetForm(form1); NewForm(form1); Back()


timl
Super User
Super User

Thanks for sharing that @Beat 

great to see the thread is still alive!

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (3,131)