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

What is PowerApps in SharePoint

What is PowerApps in SharePoint enabled applications? PowerApps is part of Office365 and work with SharePoint Online. If you have an Office365 account, you can access PowerApps via SharePoint or via the PowerApps interface.

This new technology will enable you to build applications that work across web and mobile. These applications can use a SharePoint list as the data source.

What is PowerApps in SharePoint Lists?

Create a SharePoint List first

To access PowerApps from SharePoint, you should create your list first. Decide on the field names and data types. Then create and save the list.

If you are planning on having dropdown boxes in your application then you can create a choice field in SharePoint to hold the values. A better way would be to create a separate list containing values for any dropdown box you intend to have.

SharePoint lists contain an attachment field type and this can be used to hold multiple attachments for a record.

Creating a PowerApps Application from SharePoint

Let’s look at SharePoint examples. There are a few ways of creating a mobile application, but one of the quickest is from the SharePoint list itself. When we think of what is PowerApps in SharePoint, we will be looking at hooking the two together. Keep in mind that it will create the bare bones of an app and you can then add in any extra functionality you need. You will see how a SharePoint online form gets created. What is created is good enough to get you going though.

The steps are as follows:

Open the SharePoint list.

At the menu above the list, select the PowerApps option followed by ‘Create an app’.

What is PowerApps in SharePoint

Give your app a name and click the ‘Create’ button.

Wait a few seconds while the app is built.

You will then see the interface with the app that it has created.

PowerApps in SharePoint

The app is fairly simple – it will allow you to

  • add data
  • edit data
  • save data
  • search
  • sort data
  • delete data

Any new records you create will be written back to the SharePoint list. This also applies to any record you update. Let PowerApps save data to SharePoint list data sources.

You can then share the app with others who have an Office365 account in your organisation.

Once you publish it, you and others who have access to it, will be able to view it on a phone or tablet. This should give you an idea now of what is PowerApps in SharePoint.

This is one way of creating forms. You can of course create custom SharePoint forms with PowerApps.

If you make changes to the structure of your SharePoint list, then you must refresh the list within the PowerApps application. Otherwise you will not have the correct list information and your app may not behave as expected.

Refreshing the list within PowerApps is easy. You can either refresh it from the data sources list…

Or by using the ‘Refresh’ command.

Refresh(data source name)

SharePoint List Permissions

Permissions will need to be set on the SharePoint list for users to be able to read and write data from PowerApps.

Users who don’t have at least Contribute access to the list are NOT going to be able to create or edit records in the list using PowerApps. The actions in PowerApps are controlled by the permissions on the list itself. So, the best that Visitors can do in PowerApps is View records.  They will not be able to edit them.

Users will need the equivalent of the members group if they are going to edit any content in the app.  They can only view content with just read permission.

In general, if you are using a list for a data source then all the users of the app are going to need to have at least Contribute or Edit permission, if they are going to create new records.  More permissions than that are not really going to do anything. Less permissions than that will only work for users to use an app that only views the records.

In PowerApps, the only permissions you set are to share the app and specify whether the other user will be able to edit the app or not. Those PowerApps permissions don’t actually have anything to do with the data source.

PowerApps Courses

PowerApps in SharePoint online tutorial courses will get you up to speed fast. PowerApps for newbies can take your learning to another level and give you a head start in this new technology.

What is PowerApps in SharePoint online is a combination of technologies that work really well together.

Also check: What can PowerApps do


Pin It on Pinterest

Welcome to PowerApps Support
Can we help you?