Showing results for 
Search instead for 
Did you mean: 
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.




Regular Visitor

is there is any way to check collection as changed?

Super User
Super User


There is no way to easily compare one collection to another (i.e. your Gallery).


Simply setting a variable as was mentioned by @jatcube is an option, but it will not give you the row level ability to determine what is changed.  And, more importantly, when you go to write changes, would cause you to write all of your data - changed or not.


There are two other options that are more efficient:

1) Utilize an in-memory database (collection) of changed rows.  Instead of a flat out - set a variable to true or false, instead, collect the ID (primary key) of your row in a collection.  This would utilize all of the OnChange actions of your controls in the gallery.  Each would simply have the following: Collect(colChangeList, ThisItem.ID)

This list can be checked when the user attempts to go back (i.e. CountRows(colChangeList)>0 ) to determine if there are changes.  This collection should be cleared when the screen is first shown (OnVisible).

Writing your data would be based on the colChangeList.


    ForAll(Distinct(colChanges, Value),
        With(LookUp(yourGallery.AllItems, ID=Result),
           {ID: ID,
            ColX: controlForColX.Text, 

While this will work, it will record any change and not reflect if a user "unchanges" data.  In other words, they change something and then change it back.  In this scenario, the record would still be written.


2) Employ a checkbox or toggle control in your gallery row.

In this scenario, you would set the Default property to do comparison from your underlying data to the values entered in the controls.  If there are any differences, the control will be "true".  That can be used later to write the data and also determine if there are changes prior to going "back".

For example on the Default property, the formula would be like:

!(ThisItem.ColX = controlForColX.Text) ||
!(ThisItem.ColY = controlForColY.Value) ||

To then determine if there are changes, you would simply look to see if there are any checkboxes/Toggles that are true.


CountRows(Filter(yourGallery.AllItems, yourCheckBox.Value))>0


And then your write-back formula would be more like this:

    ForAll(Filter(yourGallery.AllItems, Checkbox.Value),
       {ID: ID,
        ColX: controlForColX.Text, 

With the scenario, if a user changes a record and then sets it back, your app will not waste time in updating the record.


Hopefully this is all clear and helpful.

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!
New Member

That's simple, please apply the following steps : 

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

This should work for you.

Helpful resources

Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (3,779)