cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Steelman70
Power Participant
Power Participant

How to prevent new item form from submitting twice?

I have a button to submit a form (Form1) for a new item in my new item screen.  I copyed all the logic from the budget app template.

 

The "Save" button has this property:

OnSelect = SubmitForm(Form1)

 

Form1 has this property:

OnSuccess = Navigate(Landing,ScreenTransition.Fade);ResetForm(Form1)

 

However there is no indication that the button has been successfully pressed, so that I pressed it twice and created two new identical records in my data source.

 

Does any one have a good idea how to prevent submitting a new item form twice?

 

Maybe you disable the button as soon as it is pressed?  Is there a correct way to do this?

1 ACCEPTED SOLUTION

Accepted Solutions
mr-dang
Community Champion
Community Champion

In version 2.0.412, PG added a AutoDisableOnSelect property for buttons. If you set it to true, the button will grey out if it is selected.

 

If you are looking for a manual solution to be sure the button gets disabled, try this:

UpdateContext({load: true});

[your Patch, Update, UpdateIf, SubmitForm code here];

UpdateContext({load: false})

Set the Disabled property of the Button to the variable "load." The load variable will turn on upon the click of the button. It will turn off once writing to your datasource is complete.

 

If you want to get real fancy, also add an image box that covers your screen. Set its Image property to an animated GIF and its Visible property to the load variable. The GIF will block everything until the operation is complete. If you get impatient, then set the OnSelect property of the GIF to:

UpdateContext({load: false})

 

 

Microsoft Employee
@8bitclassroom

View solution in original post

3 REPLIES 3
mr-dang
Community Champion
Community Champion

In version 2.0.412, PG added a AutoDisableOnSelect property for buttons. If you set it to true, the button will grey out if it is selected.

 

If you are looking for a manual solution to be sure the button gets disabled, try this:

UpdateContext({load: true});

[your Patch, Update, UpdateIf, SubmitForm code here];

UpdateContext({load: false})

Set the Disabled property of the Button to the variable "load." The load variable will turn on upon the click of the button. It will turn off once writing to your datasource is complete.

 

If you want to get real fancy, also add an image box that covers your screen. Set its Image property to an animated GIF and its Visible property to the load variable. The GIF will block everything until the operation is complete. If you get impatient, then set the OnSelect property of the GIF to:

UpdateContext({load: false})

 

 

Microsoft Employee
@8bitclassroom

View solution in original post

hpkeong
Community Champion
Community Champion

Hi

 

In fact, this was discussed earlier on how to prevent NOT ONLY pressing twice on SAVE button (wheere now it has included AutoDisableOnSelect, set to true).

Dang used something to cover the whole page, and I used to set all items (press Ctrl-A) and set Disabled: XX, and when pressing save, UpdateContext(XX: true). That will prevent from changing any INPUT while saving (because sometimew it will take a little longer due to slpw internet connection).

 

Just sharing.

 

hpkeong

Hello guys this is very helpful but i was thinking of the possibility of limiting the entry for each office 365 user once per day. Any ideas?

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!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Users online (2,315)