cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
rocky5
Regular Visitor

How to prompt popup when gallery items not saved

 

I changed data in text and dropdown values which is there in gallery and when i click on back button it should popup there is unsaved values else it should be back page.

 

issue1.png

issue2.pngissue3.pngissue4.png

1 ACCEPTED SOLUTION

Accepted Solutions
Aimen_Boulahia
New Member

That's simple, please apply the following steps : 

  1. For this screen, OnVisible property initialize the following context vartiable with false value  : 
    UpdateContext({ThereIsChanges:false});
  2. No, for each input on your gallery, OnChange property update the variable with true value : 
    UpdateContext({ThereIsChanges:true});
  3. For your Back icon, OnSelect property if there is any changes then trigger the popup : 
    If(ThereIsChanges,UpdateContext({ShowPopUp:true}));
  4. For your Save Icon, OnSelect property : UpdateContext({ThereIsChanges:false});

This should work for you.

View solution in original post

12 REPLIES 12
RandyHayes
Super User
Super User

@rocky5 

You will need two things:

1) Some indicator (formula) to determine that there are actually changes.

2) A popup series of controls (I would recommend this in a Component to be reusable).

 

Without knowing any more details about your scenario, this is about all I can suggest at this point.

 

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.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

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

I created a popup already but i am not sure how to write formula 

jatcube
Solution Supplier
Solution Supplier

@rocky5 we can only help more if you give us more specifics of your app and may help to attach screenshots too.

cwebb365
Super User
Super User

In order to prevent hitting back, you need to select the top level app page and then set the "Confirm Exit" to true. Then set a message. This is the only way to prevent closing of the app without putting up a message etc. Giving them the option to leave or cancel.  

*This assumes by back you mean browser back button. If you mean a back button/icon/image you created in your app, then it's a different scenario :). 

@rocky5 

Tell me more about what you have designed.  However, more importantly is going to be - how are you determining if there is a change?  You mention this is a Gallery...what are you doing in the Gallery to enact changes?

_____________________________________________________________________________________
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.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

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

@RandyHayes  i have updated with pictures in post can you let me know how to do with above changes

@jatcube i have updated with pictures in post can you let me know how to do with above changes

@cwebb365 i have updated with pictures can you let me know how to do with above changes

jatcube
Solution Supplier
Solution Supplier

@rocky5 the simplest solution I can think of is using the

OnChange

property of your controls to set a variable to true, such as

Set(varDataChanged, true)

and then check for that condition when user clicks on the back button, such as

OnSelect = If(varDataChanged, 'showPopUp', Back())

 Of course, this is very simple logic and doesn't tell you if data actually did change, or whether the control was just used, but it may be enough to simply prompt the user that there may be unsaved changes. If you want to be a bit more specific, you can set a hidden checkbox per row to true and then you can point the user to the row that may have unsaved data. Something like this maybe? Add check box in every row of gallery and use collection object to store selected record | Softchief...

 

Or you can compare default values to current values on controls and then set the variable.

 

As I said, many ways to go about this, really depends on what you want exactly and how critical is it that you identify individual changes.

 

How do you save the data by the way?

If you found this response useful, give it a thumbs up and don’t forget to mark your post answered to help others find the solution easier.

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Power Apps Ideas

Check out the New Ideas Site

We are excited to announce a new way to share your ideas for Power Apps!

Top Solution Authors
Top Kudoed Authors
Users online (4,340)