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

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]')
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]')
vsslasd
Level: Powered On

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
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

SecondImage

PowerApps Monthly Community Call

Next Wednesday, August 21st at 8am PDT

Top Community Contributors for July 2019

Top Community Contributors for July 2019

Let's thank our top community contributors

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

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

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

FifthImage

Dynamics 365 and Power Platform April 2019 Release notes

Features releasing from April 2019 through September 2019!

SixthImage

Power Summit Australia 2019

August 20-23rd 2019

Users Online
Currently online: 206 members 3,679 guests
Please welcome our newest community members: