cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
vsslasd
Level 8

Refresh('[dbo].[vwView]') & ClearCollect(viewcollection, '[dbo].[vwView]')

We are trying to understand the Refresh vs. the ClearCollect.

 

Is a Refresh required prior to issuing a ClearCollect, or does the ClearCollect automatically execute a Refresh prior to returning the data from the views with the most up-to-date data ?

 

For example:

 

Do I need to execute the following to get the most up-to-date data from SQL Server:

Refresh('[dbo].[vwView]')
ClearCollect(viewcollection, '[dbo].[vwView]')

or does the following command:

ClearCollect(viewcollection, '[dbo].[vwView]')

 

execute the refresh when it performs the clearcollect getting the most up-to-date data?

 

Thank you

1 ACCEPTED SOLUTION

Accepted Solutions
PowerApps Staff CarlosFigueira
PowerApps Staff

Re: Refresh('[dbo].[vwView]') & ClearCollect(viewcollection, '[dbo].[vwView]')

If you want to ensure that you have the most up-to-date information from a view in SQL Server, then you need to call Refresh on it. PowerApps may cache the data from data sources (such as SQL Views) until it knows that the cache is stale. For regular tables there are some cases where it knows that the cache is stale, for example, if a new record is added to / removed from the table, or if a record is modified. But (as of now), there's no way to tell that a view is dependent on some action on another data source, so if you want to ensure that you're getting the most recent data, you need to refresh it first:

Refresh('[dbo].[vwView]'); ClearCollect(viewcollection, '[dbo].[vwView]')

View solution in original post

3 REPLIES 3
PowerApps Staff CarlosFigueira
PowerApps Staff

Re: Refresh('[dbo].[vwView]') & ClearCollect(viewcollection, '[dbo].[vwView]')

If you want to ensure that you have the most up-to-date information from a view in SQL Server, then you need to call Refresh on it. PowerApps may cache the data from data sources (such as SQL Views) until it knows that the cache is stale. For regular tables there are some cases where it knows that the cache is stale, for example, if a new record is added to / removed from the table, or if a record is modified. But (as of now), there's no way to tell that a view is dependent on some action on another data source, so if you want to ensure that you're getting the most recent data, you need to refresh it first:

Refresh('[dbo].[vwView]'); ClearCollect(viewcollection, '[dbo].[vwView]')

View solution in original post

vsslasd
Level 8

Re: Refresh('[dbo].[vwView]') & ClearCollect(viewcollection, '[dbo].[vwView]')

Thank you, can you tell me when PowerApps: "until it knows that the cache is stale. "

PowerApps Staff CarlosFigueira
PowerApps Staff

Re: Refresh('[dbo].[vwView]') & ClearCollect(viewcollection, '[dbo].[vwView]')

For views PowerApps doesn't have a way to know that it's stale (unlike tables, where it will know that a cached item is stale if there were update operations for that item, for example). I don't know if there is an internal "timeout" mechanism that marks a connected data source as stale after a period of time, but even if there is such a thing, this is an implementation detail that the apps shouldn't rely on. If you want to ensure that you have the latest data from a view (or even from a table, as other users may have made updates while you were using the app), you need to pull the latest data using Refresh.

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors
Users Online
Currently online: 174 members 5,690 guests
Please welcome our newest community members: