cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
GeorgesElias
Level: Powered On

Submit save forms and stay in the page

Hello,

 

im creating an app connected with SharePoint list in a single screen called (HomePage)

homepage.PNG

 

save.PNG

 

When i click on "Enregistrer" (means save), he's saving the data in the sharepoint list and he give me this : 

enregistrer.PNG

 

in the OnSelect i put : SubmitForm(Form)

What i want is when i click on "Enregistrer" , i want him to save and go back to the same page with a new form.

How can i do that ?

 

Thanks

tchin-nin
Level 10

Re: Submit save forms and stay in the page

Hi @GeorgesElias,

 

Yes you can do that, you need to update the OnSuccess property of your form to :

NewForm(Form)

 

That basically means, when the submission is successfull, make my form ready for a new item creation.

 

Théo

rebeccas
Level 8

Re: Submit save forms and stay in the page

On the button put =SubmitForm(frmName);ResetForm(frmName);NewForm(frmName)

tchin-nin
Level 10

Re: Submit save forms and stay in the page

HI @rebeccas

It is better to put the NewForm() function on the OnSuccess property of the form like I've suggested because you don't want the user to loose all what he has filled in if the submission fails. 

I'm not you need to sure Reset() IMHO because with the NewForm() you're already resetting his Mode that should reset the controls ?

 

Théo

 

rebeccas
Level 8

Re: Submit save forms and stay in the page

It goes in whatever order you put so as long as you put the Submit first it should be good......but either way works I suppose.

 

It depends on what fields you are doing whether you need the Reset in there....I have some with RadioButtons and checklist and stuff like that and without out it doesn't seem to clear that out. There is extra code I can put in there to force it but I just use the ResetForm to cover the basis and saves me time. Just have to remember to use it BEFORE the NewForm part or it will change your FormMode from New to Edit (been there, done that!).

Highlighted
tchin-nin
Level 10

Re: Submit save forms and stay in the page

Yes it goes in the order of the formula. But if the NewForm function is right after the SubmitForl function, the app will chznge the form mode even if the submission fails, and this is not a correct behavior, if the submission fails the user should stay on the form he has filled in, correct his error and resubmit it. That's why using the OnSuccess property is better. 

 

Haven't tried for radio and checkbox so you may have a workaround. But resetting the form control before changing the mode can be a bed idea if your default value on your controls is conditional to the mode. 

 

Théo

rebeccas
Level 8

Re: Submit save forms and stay in the page

Everybody’s has their own way I guess...I have built about 40 apps now and use it that way all the time and haven’t had the first issue with it on any of my apps so I’m not going to change it up now.

To each his own :-)
rebeccas
Level 8

Re: Submit save forms and stay in the page

The reason I don’t like using the OnSuccess is because I like my actions visible...I do a lot of Apps (two this week alone) and when I open them to add in fields or do upgrades it is easier to remember what stuff do when it is more visible and not split out in a bunch of different places.

Almost all of my apps are tied to SP List so maybe it is an issue with other data sources but I’ve never had any problems doing it this way with mine.

I have a few simple ones but most of mine are pretty complicated so anything I can keep simple I do.

But like I said...everybody has their own preference and style. Almost everything in PowerApps has about three different ways you can do the exact same thing it just depends on your needs and personal preference.
tchin-nin
Level 10

Re: Submit save forms and stay in the page

I agree 100%, there is a lot a ways to do things and everyone has is own, all depending of development preference, and business needs.

But IMO doing thing onSubmit and OnSuccess are 2 different things. Of the user is submitting an item on the train and lost his internet connectivity, it is pretty good to handle the case where the submission fails.
But like you said, all depends on business and technical requirements, I don't know your apps you are the only judge of what's good for you as a developer and for your users, as long as you have anticipated all behaviors.

I am not arguing, just debating Smiley Happy this is what is good as well with the community, the possibility to debate and understand other's way !

Théo
rebeccas
Level 8

Re: Submit save forms and stay in the page

Oh I agree tons of ways of doing it...I always require fields other than the ones required by SharePoint and my button is disabled until they have all the fields required put in so that is probably why I never have any of those issues.

😁