web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Please help! Unsaved c...
Power Apps
Answered

Please help! Unsaved changes

(0) ShareShare
ReportReport
Posted on by

If I create/edit a new record in a form and I haven't started typing any data in the fields of the form yet, which would be a blank form, then I decide to click the back button without saving it, it should go back to the browse screen. 

If I create/edit a new record in a form and I start typing any data in the field of the form, then I decide to click the back button without saving it, it should prompt me for a popup that there are unsaved changes and will ask me for "Are you sure you want to go back?". If I click yes, it will save and go back to the browse screen, if I click, no it will not save the changes and will go back to the home screen. If I click cancel, the pop would disappear and remain on the same screen with the unsaved changes. How do I accomplish this?

Categories:
  • iAm_ManCat Profile Picture
    18,256 Most Valuable Professional on at

    Are you referring to a back button within your App?

     

    Create an overlay/popup that is visible if gblUnsavedChanges=true and back button is pressed.

     

    Whenever the OnChange for any of the fields in the form is triggered, set gblUnsavedChanges to true. On the page's OnVisible, set gblUnsavedChanges to false.

     

    When your back button is pressed, if there's no unsaved changes, (variable =false) then navigate back, otherwise set variable gblBackButtonPressed, and make the overlay only visible if that variable is true. Your cancel button on that popup then set gblBackButtonPressed to false, hiding the overlay, and your ok, navigates back and resets the form.

  • teach20 Profile Picture
    on at

    Thanks for helping out! It works! However, if I start typing in the field and then deleting it to blank, when I click back, the pop-up still displays. Basically, what I want to happen below is if I clear any changes of the fields to blank of the new form, and if I click back, it shouldn't show if there are any unsaved changes. Here's the video. https://clipchamp.com/watch/VPZ4UC0cugP



    My current code of the OnSelect of my back button is:

    If(varUnsavedChanges = true, Set(varGblPopUpCancel, true), Navigate(scrBrowseProjects))

     

  • Verified answer
    iAm_ManCat Profile Picture
    18,256 Most Valuable Professional on at

    Mmm, that's where we start getting to the difficult side - notifying when anything has changed in any way is much easier than checking if everything is back to default... Especially since you have radio buttons. I don't know if you realise but you can't unselect radio buttons, so they can never return to the default state of nothing being selected, so you can't check them for validation in terms of unsaved changes being reverted to blank.

     

    You can take the formula below and expand it for all the other textboxes / datepickers / dropdown / comboboxes / etc in your form, one by one (see where my comment is)

    OR

    You can have a basic 'something changed, are you sure you want to leave?' popup (I suggest sticking with this)

     

    If(
     varUnsavedChanges = true
     &&
     // here we check if items have no length
     // this confirms that they ahve been returned to blank
     // but you need to then check for each one individually
     // as you can't just check 'all items in my form are back to default'
     !(
     Len(ProjectNameInput.Text)=0
     &&
     Len(ProgramNameInput.Text)=0
     &&
     Len(DivisionDropdown.Selected.Division)=0
     //Add in here any other textboxes/dropdown/datepickers/etc you have
     ), 
     Set(varGblPopUpCancel, true), 
     Navigate(scrBrowseProjects)
    )

     

  • teach20 Profile Picture
    on at

    This worked! I had to convert the radio choices to a combobox, which did the trick! Thank you!

  • iAm_ManCat Profile Picture
    18,256 Most Valuable Professional on at

    Excellent, glad to help, hope you have a good weekend!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 342 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 258

#3
Mohsin Ali Profile Picture

Mohsin Ali 231

Last 30 days Overall leaderboard