One of the known limitations with Power Apps Components is that collections are not supported.
The above link clearly states that
- Power Apps doesn’t support collections in components.
Does this mean that you can’t use collections in your components?
Power Apps Components Limitations
However when you create yourself a collection/Table parameter and expect to use this collection inside your component then you will discover the limitation quite quickly.
So how can we use data in a collection then?
Generating a collection
As an example I’m going to use the GetAdminApps function from the PowerAppsforAdmins connector.
The function takes the name of an environment as a parameter. This parameter can be supplied as a component parameter.
This now means that a gallery’s items can be collected like this:
Even though the Component will show you the following error, inside an app the component will work
In my app I can now see the results and as I select different environments I will see different results coming back. In the example below an environment holding 2 apps results in 2 records being returned.
That is a great first step, however I might want to reuse the component.
You could now for example inside your app specify a collection. Then use the filter function inside the Component to filter by parameters supplied by component properties.
The important factor is to keep the datasource for the component the same, however parameters can be different. It is important to understand that at design time the data model may need to be known for Power Apps to be able to validate the app. Hence varying the datasource is not going to work.
To make component development easier you might want to temporarily set the items in your gallery to specific data.
In my previous example instead of using the following expression:
I initially used something like the below:
This way my Power Apps component showed be actual data. Once I was happy with the component all I had to do was replace the hard coded environment guid with the component property name and ignore the error warning in the component.
Other Components posts
How to size Power Apps components dynamically in 1 easy step!