I am working on an app where I want an action to execute when the app is closed. Specifically, I want to use the slack connector to send a chat to a channel notifying my team that a user is done using the app.
I know there's the OnHidden function for a page, but my guess is that only works when navigating away from the screen while the app is still open.
Is anything similar where I could have the app execute a function when the user closes out of the app?
Nope, not in Power Apps. You can vote for the idea here:
What you can do instead is execute a function when the user finishes a process (e.g. clicks submit button). This is a better design pattern because the user knows their work was sent successfully. If there was an error, the user would never know.
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."
As @mdevaney mentioned, there is NO current OnAppClose action that you can hook onto.
The best you can do currently is to provide a Close button/icon/etc that a user must use to close the App. You can intercept the app closing by using the ConfirmExit property of the App. In that you can set the ConfirmExitMessage property to tell the user they need to click on your button/icon/etc to close the app - However unfortunately, that dialog that opens presents two buttons to ask the user if they want to cancel or close. There is nothing that keeps them from just clicking on close.
BUT...it's something and perhaps may be helpful for you in the meantime while we wait for an OnClose action.
I hope this is helpful for you.
I personally don't hold out much hope for the OnExit event. People would probably overload it with way too much stuff like they do OnStart.
But yeah, even a close button with the Exit() function doesn't prevent anything. IMHO, the original poster must train those users how to use the app properly and show a confirmed save message in the app.
I'm not holding my breath for it!! And yes, I can only imagine how much stuff people would try to stuff into the OnExit. Yikes!!
I believe it would be nice to at least allow some control over the ConfirmExit where you can prevent it from showing the "Exit" option. So that the user would have to go back to the app and exit properly from there.
The only place I've ever really run into this factor has been on Offline apps where there might be some "fresh" information that can't be sent to the mothership because of no connect and we have not saved it to the device for later processing. In those cases, we give a stern warning in the exit message that they WILL LOSE DATA. That seems to stop them to some degree. Or at least, when they come complaining that they lost data, we can point back to the warning they were given.
This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.
Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.
At the monthly call, connect with other leaders and find out how community makes your experience even better.