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 / How to force user to e...
Power Apps
Answered

How to force user to either save or discard data when trying to navigate to different screen?

(0) ShareShare
ReportReport
Posted on by 18

I have a basic form that allows users to input data into textboxes and a save button to patch the data. I want to be able to create a popup that alerts the user if they want to save or discard their changes when they try to navigate to a different screen to eliminate and reduce data loss. How would I implement this or is there a specific function that I can use to check if users are going into a different screen? Any tips or suggestion is greatly appreciated! 

Categories:
  • Verified answer
    Ami K Profile Picture
    15,689 Super User 2024 Season 1 on at

    @sygc601 - assuming your "basic form" is an EditForm control, you can leverage the Unsaved property.

     

    For example:

     

    1. On the OnSelect property of your Save button, enter:

     

    If(
     'Your Form'.Unsaved && 'Your Form'.Mode = FormMode.Edit,
     UpdateContext({ctx_show_unsaved_dialog: true}),
     Navigate(
     Screen1,
     ScreenTransition.Fade
     )
    );
    

     

    2. Insert a Container control into your Screen

    3. Insert a Label control into the Container and enter a warning message. E.g. 

     

    "If you exit this screen any unsaved changes will be lost. 
    
    Are you sure you want to exit this screen?"
    

     

    4. Insert a two Button controls inside the Container (a "Yes" Button and a "No" Button).

     

    5. On the OnSelect property of the Yes Button, enter:

     

    UpdateContext({ctx_show_unsaved_dialog: false});
    Navigate(
     Screen1,
     ScreenTransition.Fade
    )

     

    6. On the OnSelect property of the No Button, enter:

     

    UpdateContext({ctx_show_unsaved_dialog: false})

     

    7. On the Visible property of your Container, enter:

     

    ctx_show_unsaved_dialog

     

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 248 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 192 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 135

Last 30 days Overall leaderboard