cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Lefty
Impactful Individual
Impactful Individual

disable save button if no change to data

Hi

I seem to have a problem.

When a user clicks the save button to submit the data on my form to SharePoint, those impatient users, are clicking the save button more than once, and its creating more than 1 item in SharePoint.

I'm sure others have faced the same issue, my thought was to disable the save button unless there is a change made on the form, different to the data source?

If this is a good way, can someone advise how I achieve this, or if someone has a better way of dealing with this, please advise?

 

Thanks 

1 ACCEPTED SOLUTION

Accepted Solutions
Eelman
Community Champion
Community Champion

@Lefty 

If that's the case, you could set a Wait variable in the App OnStart then any controls could use it throughout your app

 

eg

// app OnStart
Set(wait, false);

// submit form
Set(wait, true); SubmitForm(..);

// any controls eg buttons
Button.DisplayMode = If(wait, DisplayMode.Disabled, DisplayMode.Edit);

// onSuccess
Set(wait, false); ... your other code ...

 

Or similar

View solution in original post

9 REPLIES 9
Eelman
Community Champion
Community Champion

@Lefty 

I've just recently started using a screen transition, using the Navigate() function, to stop users doing this with Patch & SubmitForm. It can be a little disconcerting for users, depending on the process, but hey it helps the developers out heaps!

WarrenBelz
Super User
Super User

Hi @Lefty ,

If you want it enabled once per screen visit, set a Variable at screen OnVisible

UpdateContext({vSave:true})

On the Save button OnSelect

All the save stuff;
UpdateContext({vSave:false})

The DisplayMode of the button

If(
   vSave,
   DisplayMode.Edit,
   DisplayMode.Disabled
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Lefty
Impactful Individual
Impactful Individual

@Eelman 

Like, when a user clicks the save button, the first thing that occurs is navigate to another screen?

If yes, what if the submit fails as my send email code is on the OnSuccess of the form and if its successfully submitted i then navigate the user to a SucessScreen.. not sure how this would then work? 

Lefty
Impactful Individual
Impactful Individual

Hi@WarrenBelz 

 

Thanks, definitely an option I could use, i'm just thinking from a user experience, it won't be ideal if they need to refresh the page and then navigate to around Screen6 before they can make a change to the form?

@Lefty ,

That can be catered for too - if you have a refresh button, reset the variable to true in this.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Eelman
Community Champion
Community Champion

@Lefty 

If that's the case, you could set a Wait variable in the App OnStart then any controls could use it throughout your app

 

eg

// app OnStart
Set(wait, false);

// submit form
Set(wait, true); SubmitForm(..);

// any controls eg buttons
Button.DisplayMode = If(wait, DisplayMode.Disabled, DisplayMode.Edit);

// onSuccess
Set(wait, false); ... your other code ...

 

Or similar

Lefty
Impactful Individual
Impactful Individual

@Eelman 
Thanks this makes sense to me and I've implemented it, cant fully test this as its only in certain scenarios where the save/submit takes more than a few seconds to complete, so until that happens i cant see if this functions they way i want it to , but it should.

👍

Lefty
Impactful Individual
Impactful Individual

@Eelman 

 

This is what I have done App OnStart:

Set(vWait,false);
On the Save buttons OnSelect:

Set(vWait,true);
SubmitForm(Form1);
OnSuccess of the form:

Set(vWait,false);

 

A thought occurred, if the OnSuccess does not trigger, the button will stay disabled right? have I missed something from your suggestion?
Or maybe I can set the vWait variable to false at OnFailure too?

Eelman
Community Champion
Community Champion

@Lefty 

Yep, that makes sense, I'd cover all bases and reset your vWait variable if the submit failed. Good call!

 

👍

Helpful resources

Announcements
Super User 2 - 2022 Congratulations 768x460.png

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

<
Users online (2,219)