cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Zgolbarg
Helper III
Helper III

Reset items after submit

Hi,

I have this code in the Onselect property of submit button:

 

If(
IsEmpty(
Errors(
'Project Request (Projects@Mayk.com)',
Patch(
'Project Request (Projects@Mayk.com)',
Defaults('Project Request (Projects@Mayk.com)'),
{
Title: txtInputTitle.Text,
'Team Project Type': drpTeamType.Selected,
'Sub Project Of': drpSubproject.Selected,
'Request State': drpRequest.Selected,
Priority: drpPriority.Selected,
'Start Date': dpkStartDate.SelectedDate,
'Due Date': dpkDueDate.SelectedDate,
'Market Live Date': dpkLive.SelectedDate,
'Billing Comments': txtInputComment.Text,
Fixed_Fee_Amount: Value(txtInputFee.Text),
'Project Type': drpProjectType.Selected,
Billing_Type: drpBillingType.Selected,
Company: drpClients.Selected,
Bill_To_Client: drpBillToClient.Selected,
'Project Sponsor': CmdSponsor.SelectedItems,
Bill_To_Person: drpBillToName.Selected

}
)

)
),
Notify(
"Patch Succes",
NotificationType.Success
),
Notify(
"Patch Fail",
NotificationType.Error
)
);

 

I want to reset any item to default value and I used this formula for each item:

reset.drpclients.selected

 

It does not give me any error but it does not work.

 

Can help me with that?

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@Zgolbarg 

You can actually use a form in your app without the user ever seeing it or interacting with it.  Forms provide so much for you and take so much time out of your app design work and troubleshooting.  

I have a video on Forms and everything you ever wanted to know about forms.  It is a long video, but very comprehensive and it is indexed so you can review only certain parts.  Particularly, this section on "Super Forms" uses a Form as the back end for all the data actions but the users never see that form and they all interact with a completely custom look (very custom look!)

So, don't discount forms just because you have a custom look.  The form is the most powerful component in PowerApps!  It will do SO much for you that you otherwise 

 

So for the other video I sent you, yes, that one uses a toggle to reset the entire screen.  It is meant for doing more than just a simple reset of the controls, it is meant to also be a place where you can isolate formulas that need to reinitialize or do other actions.

The toggle is hidden from users - it is not meant to be visible. 

 

But, in your scenario, you really only need to use the this after your patch statement:

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

And you just need to put lclResetFields in the Reset property of all of your controls that you want to reset.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

5 REPLIES 5
RandyHayes
Super User
Super User

@Zgolbarg 

You cannot set a property directly like that in PowerApps.  The reset action needs to be used, or you need to have the Reset property of each control respond to some other value.

Personally, I don't like to repeat any formulas when designing an app, so I would opt to create a control to do all of this for you.

I have a video on doing resets that would be interesting to view.

 

In general, you can use a variable to "fire" the reset.   So, at the end of your long Patch formula (you might want to consider using a form rather than a long patch statement like that), you would put a statement such as this:  UpdateContext({lclResetFields: true}); UpdateContext({lclResetFields: false})

Then, in the Reset property of all of your controls, set the property to : lclResetFields

 

They will all reset then when you do this.

 

I hope this is helpful for you.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Hi,

The reason that I didn't use the form was that I need a custom design like having different sections, to be able to identify left or right columns manually, etc and I didn't know how to do that with Form.

 

I watched your video but I don't want to put extra control in the app since it is not user-friendly for the clients and I have not seen an extra button to clear the data in the app. Usually, data will back to default after submission.

 

for the variable in the Reset property of each item  I just need to put this variable or set it to false or true?

 

 

RandyHayes
Super User
Super User

@Zgolbarg 

You can actually use a form in your app without the user ever seeing it or interacting with it.  Forms provide so much for you and take so much time out of your app design work and troubleshooting.  

I have a video on Forms and everything you ever wanted to know about forms.  It is a long video, but very comprehensive and it is indexed so you can review only certain parts.  Particularly, this section on "Super Forms" uses a Form as the back end for all the data actions but the users never see that form and they all interact with a completely custom look (very custom look!)

So, don't discount forms just because you have a custom look.  The form is the most powerful component in PowerApps!  It will do SO much for you that you otherwise 

 

So for the other video I sent you, yes, that one uses a toggle to reset the entire screen.  It is meant for doing more than just a simple reset of the controls, it is meant to also be a place where you can isolate formulas that need to reinitialize or do other actions.

The toggle is hidden from users - it is not meant to be visible. 

 

But, in your scenario, you really only need to use the this after your patch statement:

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

And you just need to put lclResetFields in the Reset property of all of your controls that you want to reset.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

@RandyHayes 

 

Thanks a lot for all the info.  I will design my next app with the aid of Form definitely. I didn't know too much about the form.

 

I used the variable and it worked.

 

Appreciate your help

RandyHayes
Super User
Super User

@Zgolbarg 

Yes, one of the number one things to learn in PowerApps is the Form.  That video I mentioned on the forms will give you everything you need to know...and more!

 

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Power Apps Community Call Jan. 2022 768x460.png

Power Apps Community Call

Please join us on Wednesday, January 19th, at 8a PDT. Come and learn from our amazing speakers!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Top Solution Authors
Top Kudoed Authors
Users online (1,028)