Automatic Refresh in PowerApps

PowerApps

I prefer to remove the standard refresh buttons from my PowerApps screens. Instead, I build automatic refresh into action states like OnVisible for screens. When a screen becomes visible, data is refreshed and my app’s users see the latest data.

Here are my two favorite methods for automatically refreshing data:

OnVisible Property

Adding a Refresh() function to a screen’s OnVisible property is a nifty way to have the app handle refreshing so the user automatically see the latest information.

A good practice is to use the Refresh() function on screens containing calculated values about datasource records (like the Welcome Screen from my previous Welcome Screen post and any screen displaying a gallery.

The Refresh() function is easy to use, too.

  1. Simply navigate to the desired screen, and select the OnVisible property for the screen. In the formula bar, type:

    Refresh([@’YourDataSource’])

    Swap YourDataSource with your actual data source name. Done! In just one setup step, data is refreshed when the particular screen becomes visible.

OnTimerEnd

My other favorite method for refreshing data automatically is by Timer control. By adding a timer to the screen and setting its duration and a few other key options, data can be refreshed in regular intervals.

  1. Navigate to the desired screen.
  2. Add a Timer control to the screen from the Insert tab in the Input group.
  3. Select the OnTimerEnd property for the screen. In the formula bar, type:

    Refresh([@’YourDataSource’])

    Swap YourDataSource with your actual data source name.
  4. In the Timer properties panel, toggle the Repeat and Auto start properties on.
  5. Toggle the Auto pause property off.
  6. Set the Duration to 300000. (The duration field is in milliseconds. 300000ms = 5 minutes. For your app you can decrease/increase the value but beware of refreshing too often with large datasets as it could render the app experience less pleasant.

    At this point, you can test the app with the timer showing. Keep in mind you will have to wait five full minutes before refresh happens.
  7. Lastly, I don’t actually enjoy seeing the timer control. Toggle the Visible property off for the Timer control to hide it.