Auto refresh data in Power Apps

Auto-refresh data in Power Apps

When you use galleries in Power Apps to display data from a data source you will need to consider refreshing data. As the data is updated by other users you might want to auto-refresh your data. This post described a pattern for this.

Display accounts in an app

I’ve created an app that uses the Accounts entity in my CDS as a data source and Accounts are being displayed.

Gallery displaying accounts from the CDS

My app has a form to add new accounts

Adding a record to accounts using a form

This all is great when I’m the only user, however when there are multiple users you might run into some refresh issues.

As one app instance adds a new account the other users will not see this new item

The gallery is not updated

 

Auto-refresh data with timer

To solve this issue I’m adding a timer to my screen displaying the gallery of accounts.

Auto-refresh data with timer

On the timer you will need to set the Auto Start and Repeat and set the OnTimerStart as shown above. this will load the data in a MyData variable. Now update the Gallery to use MyData instead of the Accounts data source.

Now as one user adds a new record.

added an item

 

After a while you will find that the gallery in both instances synchronises.

Now the gallery is updated after a while

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: