How to Create a Collection OnStart of a Power Apps?

This Power Apps tutorial explains how to create a collection OnStart of a Power Apps.

Here, I will describe Power Apps Collection OnStart, and I will also show you every step of how to create a Power Apps Collection OnStart manually.

I will also help you to create a Power Apps Collection OnStart using a SharePoint list.

Power Apps OnStart Property

Power Apps OnStart Property runs when the user starts a Power Apps app. With the help of the OnStart property, the user can get and store that data in the collection by using the collect function.

How to Create a Collection OnStart of a Power Apps

Here, I will show you how to create a Power Apps collection OnStart using two ways:

  1. Create a collection OnStart of a Power Apps manually [without any data source]
  2. Create a collection OnStart of a Power Apps using the SharePoint list

Create a Collection OnStart of a Power Apps [Manually]

Here, I will show you how to create a Power Apps collection OnStart using the data manually.

I have a Power Apps canvas app related to furniture delivery. The app has a gallery control; when the user OnStart an app, it will display the furniture arriving soon.

Create a Power Apps Collection OnStart manually

Follow the below steps to achieve this:

  • Create a Power Apps blank canvas app.
  • On the screen, insert two image controls of the furniture and turn off the visible property of both images.
How to create Power Apps canvas app Collection using OnStart property
  • In the Tree view, Click on the App [left-hand side] -> Select the OnStart property and apply the code below:
OnStart = 
  Collect(
    colNewlyFurinitureArrived,
    {
        Furniture: "Nest Sofa",
        'Arriving Date': "08/09/2023",
        Image: Sofa
    },
    {
        Furniture: "Dining Table",
        'Arriving Date': "11/09/2023",
        Image: 'Dining Table'
    }
)

Where,

  1. Collect:- Collection function name.
  2. colNewlyFurinitureArrived:- Provide your collection name.
  3. Furniture, Arriving Date, Image: These are the columns where the new types of furniture, arriving date, and image will be stored.
Create Power Apps canvas app Collection OnStart
  • Click on the App, select the More options (…) -> Then click on Run OnStart
Create a Power Apps canvas app Collection OnStart
  • On the left-hand side, click on the Variables (x) -> Expand the Collections -> Then select the Collection name, click on the More options (…) -> Then click on View Table.
Create a Power Apps Collection OnStart
  • We can see that the Power Apps collection will be created without using any data source.
How to create a Power Apps Collection OnStart

Now, we will display the Power Apps collection using a Flexible height gallery control.

  • Insert the Flexible height Gallery, select the Items property, and then provide the code as the collection name:
Items = colNewlyFurinitureArrived

Where,

  • colNewlyFurinitureArrived: Created Power Apps collection name
How to create a Power Apps canvas app Collection OnStart
  • Now, the gallery control will be connected to a created Power Apps collection as shown below:
Power Apps canvas app create a Collection OnStart

This is how to manually create a Power Apps Collection OnStart [without using any data source].

Create Power Apps collection OnStart Using SharePoint List

Here, I will show you how to create a Power Apps collection OnStart using a SharePoint list.

I have a SharePoint Online list regarding [iPhone Offers], which has different fields like:

Fields NameData Type
iPhone IDTitle
ModelsChoice [iPhone 14pro Max, iPhone 14, iPhone 13, iPhone 12, iPhone SE]
PriceCurrency
OfferSingle line of text
iPhone ImageImage
Offer Closes byDate and time
Create Power Apps Collection OnStart

Using that SharePoint list, we will create a Power Apps collection using the OnStart property.

  • Create a Power Apps blank canvas app.
  • Click on the Connect to data from the middle of the Screen page -> A dialogue box will appear [left-hand side], Click on the Add data.
Create an Power Apps Collection OnStart
  • Now expand the Connectors -> Then select the data source as SharePoint -> then select a SharePoint site, to which you want to connect.
Create a Power Apps Collection OnStart using SharePoint list
  • Now, select the SharePoint list, Then click on the Connect button. Now, the SharePoint list will be connected to a Power Apps canvas app.
Create an Power Apps Collection using OnStart property
How to create the Power Apps Collection OnStart
  • In the Tree view, Click on the App [left-hand side] -> Select the OnStart property -> Then apply the SharePoint list collection formula.
OnStart = Collect(coliPhoneOffers,'iPhone Offers')

Where,

  1. coliPhoneOffers: Provide your Collection name.
  2. iPhoneOffers: SharePoint list name.
Create the Power Apps Collection OnStart
  • Click on the App, select the More options (…) -> Then click on Run OnStart
Create the Power Apps Collection using the OnStart property
  • On the left-hand side, click on the Variables (x) -> Expand the Collections -> Then select the Collection name, click on the More options (…) -> Then click on View Table.
How to create an Power Apps Collection using OnStart property
  • Now, we can see that the Power Apps collection will be created from a SharePoint list as shown below:
Power Apps create Collection using OnStart property

Now, we will display the Power Apps collection from a SharePoint list using horizontal gallery control.

  • Insert the Horizontal Gallery, Select the Items property, and then provide the code as the collection name:
Items = 'iPhone Offers'

Where,

iPhone Offers: Created Power Apps collection name

Create the Power Apps canvas app Collection OnStart
  • Change the Layout section:
Layout = Tile and subtitle on overlay
  • Now the gallery control looks like the below image:
Power Apps create Collection OnStart property
  • Click on the Offer field -> In the Properties pane, change the Color property to black and the Fill property to green as shown below:
How to create Power Apps canvas app Collection OnStart

When the user opens or runs the app, they should receive an iPhone offer which are available as shown below:

Power Apps canvas app Collection using OnStart property

We can create a Power Apps collection using the SharePoint list as a data source by app OnStart property.

Also, you may like some more Power Apps tutorials:

Conclusion

Here, I have covered Power Apps Collection OnStart; a user can get and store that data in the collection when they run or start the app using the collect function.

I have explained every step of creating a Power Apps collection manually[without data source] using the app OnStart property using the collect function and also shown you how to display that data using a Flexible height gallery control.

Finally, I have described how to create a Power Apps collection using a data source of SharePoint list using the app OnStart property using the collect function and also shown you how to display that data using a Horizontal gallery control.