PowerApps Refresh SharePoint List

Why would you need to do a PowerApps Refresh SharePoint List function? One reason is to have the latest changes from our data source. There are times when we may make changes to our data sources. For example, we may want to add or remove fields. Perhaps we want to rename a column or two because there is a business need or it could be that we thought of a better name.

Whenever we make changes to our data source, it is not reflected back immediately in PowerApps. This is when a refresh of the data is needed.  If we have made a change to our SharePoint data source then we can quickly perform a PowerApps Refresh SharePoint List task. First head over to the PowerApps menu and select the ‘View’ option. Then click on the Data sources button. You will then see your data sources listed. Click on the ellipsis next to the one you want to select. A small menu pops and all you need to do is to select the ‘Refresh’ option.

PowerApps Refresh SharePoint List

Once the data has been refreshed you will have the latest changes to hand and can carry on with your work.

It is not only data structure changes that benefit from a refresh. The data itself can be changed and you will want to have the latest data available that includes the changes.

This is again where you can use the Refresh function because it will go and retrieve a fresh copy of the data source. You’ll then be able to see changes that other users made.

In the OnVisible property of a screen enter the refresh command. It would look something like:


If you make any changes to your SharePoint list you will need to refresh the data source in PowerApps in order to use the latest changes.

PowerApps Refresh SharePoint List

The Refresh() function only updates data from the original lists in SharePoint.  It does not refresh collections.  To do that you will need to invoke the ClearCollect() function on the SharePoint list.  It is not possible for PowerApps refresh data source functionality to work in the same way when using collections.

PowerApps Refresh SharePoint List and Update Data Table or Gallery

There may be times when you want to make use of the Data Table control. This offers a spreadsheet type of look as a grid to hold multiple values. At the time of writing this article, the Data Table control does not appear to pick up the latest data once a PowerApps Refresh SharePoint List has been done. Personally, I find this is a bit of a hindrance and tend to use the Gallery control to give me the same multiple record layout. The data table looks great when sitting on a screen, but attempting PowerApps refresh data table functionality right now would prove futile. I’m sure this problem will be addressed and fixed in the future though.

The same applies for the Gallery control. A refresh of the Gallery control can be done via the OnVisble property of the screen. If you are saving data using the Patch command, it may be a good idea to include a Refresh statement once the save has been done. That way the Gallery control will have the latest data in the data source.

Current SharePoint or SQL Data 

It is important that we always have the latest data to work with. Also, we should be working with the latest data source structure. Data is important, not only for our organisations, but for the clients we are serving.

Also Check What is a PowerApps Collection

What is a PowerApps Collection

What is a PowerApps collection used for? Collections are useful for when we want an in-memory store for data. The data held in a collection can be accessed from any screen in our app. This is particularly beneficial because it enables us to share data between the screens in our application.

It is possible to save data in a PowerApps collection to SharePoint list data sources.

To create a collection, we would write:

Collect(CollectionName, items)

For example, if we have a selection of students that we want to add to a collection we would write:

Collect(StudentCollection,      {Name:”Paul”,LastName:”Jones”},   {Name:”Sue”,LastName:”Davies”})

Add the code to the App start. The code will run each time the app loads. To see this collection in action we can add a gallery control.

What is a PowerApps Collection

We can now see that our collection appears in our data sources list.
Select StudentCollection as the data source.
Now close the app and reload it so that the app start code runs.
The gallery will now show the items in the student collection.
What is a PowerApps Collection

What is a PowerApps Collection Inside the App?

To see the items in the collection go to the menu and select ‘File’. Now select ‘Collections’. When we use the PowerApps add record to collection functionality we can see the results instantly. As you can see, PowerApps collections are useful data storage containers.
What is a PowerApps collection

What is a PowerApps Collection – Adding Data

Now that we have our collection, we might want to think about how we can add more student names to it.
Add two labels, two text box controls and a button to the screen.
PowerApps Collection

Name the text boxes to be txtFirstName and txtLastName.
On the OnSelect property of the button add the following code:
Collect(StudentCollection,{Name:txtFirstName.Text, lastName:txtLastName.Text})
This says add the values from each text box to the Name and LastName properties of the student collection.
Now run the form and enter a first and last name.
Click the button and the item you entered should appear in the gallery.
There is another command that we can use when we want to not only clear the collection, but append data to it. This is the ClearCollect command.
The syntax for this is ClearCollect(CollectionName, items)

What is a PowerApps Collection – Deleting Data

In order to delete items from the collection, we would use the Remove command as follows:
When we click on the gallery row of the record we want to delete, we are on the current item.
Add a button on the gallery row-  I prefer to use a bin icon.
On the OnSelect event add the code Remove(StudentCollection,ThisItem)
Run the screen and try it out. You should see the item you select in the gallery get deleted.

PowerApps Update Collection Item

It is also possible to update the values held in the collection.
The command to use is as follows:
Patch(StudentCollection,Gallery1.Selected, {Name:txtFirstName.Text,LastName:txtLastName.Text})
Add this code to the OnSelect event of a new button.
Run the app.
Click on an item in the gallery and enter some data in the first and last name text boxes.
Click the ‘Update’ button.
The collection values will change and you should see this reflected in the gallery.

When to use a Collection

Collections are very powerful and a useful feature of PowerApps. I like to use a collection when I am loading data to a screen. If the Patch command has been used to save the data, then a collection can store the data that is loaded back. The controls on the screen can then refer to the item in the collection.

Also Read: PowerApps Navigate to Previous Screen


Pin It on Pinterest

Welcome to PowerApps Support
Can we help you?