web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / How to use collection ...
Power Apps
Unanswered

How to use collection in component?

(1) ShareShare
ReportReport
Posted on by 249

I wanted to create a component to collect list of email addresses. Where can I define the collection?

On clicking Add, I wanted to add the email to collection and show it in a gallery control inside the component itself, as shown below diagram.

 

Also,I wanted to return the list of emails from the component

 

1.png

 

 

Categories:
  • poweractivate Profile Picture
    11,078 Most Valuable Professional on at

    @pcakhilnadh 

    Try this

    poweractivate_1-1634729517021.png

     

    1. Under Properties (of the Component) click on New custom property

    2. Click Dropdown for Data type

    3. Select "Table" from dropdown for an equivalent of Collection.

    4. Click Create

     

     

    Check if it helps.

     

    If you are unsure if a Table is same thing is Collection - I think they essentially are, actually.

    https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/working-with-tables#behavioral-formulas

    Notice in this page, the way Table is talked about is same as Collection, for example.

     

    Check if above helps.

     

    I do think there may be one difference.

    Table, for each Record I think must have same Field names across all Records.

    If they do not have the same ones, then they are Collection that is not a Table.

    Otherwise, they are Table, which also is, I believe, still a Collection too.

    I believe this might be only main difference. 

    Other than this I think they are almost the same.

     

  • pcakhilnadh Profile Picture
    249 on at

    @poweractivate 

    Could you tell how to add Value to this table ?  The purpose of using collection is to add an item to it and display in gallery.  How to perform this action is unclear from your explanation

  • poweractivate Profile Picture
    11,078 Most Valuable Professional on at

    @pcakhilnadh 

     

    poweractivate_0-1634731870870.png

    1. Click the text Custom property 1

    2. The stuff in the curly braces are the Fields- add or remove as you please

     

     

    Check if it helps.

     

    Please note this is the property of Component which is intended maybe for something else than what you are asking.

     

    Instead if you want to have just regular Collection inside Component, maybe just use ClearCollect instead from scope of Component in the initialization of the Component - maybe from OnReset property of Component for example.

    poweractivate_1-1634731969330.png

     

  • pcakhilnadh Profile Picture
    249 on at

    @poweractivate  

     

    In the example shown above, you are adding items to the table while initializing it. 

    Im looking for adding a row on button click dynamically. Basically I need to collect email address from the user and add to this table and show in the gallery. This is still unclear from your explanation.

     

    AFAIK, "Component in the initialization of the Component - maybe from OnReset property of Component for example."   this is not supported in powerapp. 

    I'm looking for alternative ways to acheive the earlier said requirement.

  • poweractivate Profile Picture
    11,078 Most Valuable Professional on at

    @pcakhilnadh 

     

    According to here Collections in Components are not supported, so be careful with it:

     

    https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/create-component#known-limitations

     

    Known limitations
    • You can't save data sources, forms, and data tables with components.
    • Collections in components aren't supported.
    • You can't insert a component into a gallery or a form.
    • A master instance of a component is a local master and scoped to the app. If you change a master instance, only copies of the component within the app will reflect the change. Copies in other apps will remain the same unless you import the component library again. All master instances in those apps will be automatically detected and updated.
    • You can't package media files when you import a component.
    • Components don't support the UpdateContext function, but you can create and update variables in a component by using the Set function. The scope of these variables is limited to the component, but you can access them from outside the component through custom output properties.


     

    Try it without a Component first. After that, try to recreate same functionality in Component, then see if you can somehow use the Table Input or Output Property to use it or access it from outside and/or to change it from outside if needed in a Component kind of way. It may be possible to still do this despite Collections not being supported (you can instead use "Table" as the data type of the Property and just put it there and pretend it is Collection) - but it may be easiest to start by implementing your functionality in an example App with no Component - then try it with a Component after that.

  • pcakhilnadh Profile Picture
    249 on at

    I've read this article and I also know how to implement it without components. The sole purpose of posting this query is to look for answers using components only. I wanted to add a new row to the table not while initializing the table input property.  Is there any solution to this issue? I would be grateful if you can suggest it.

  • poweractivate Profile Picture
    11,078 Most Valuable Professional on at

    @pcakhilnadh 

     

    Right now I'm not sure of it, I'd have to check on it further. In meantime if someone else here knows it I'd be curious as well. 

  • KASCHN Profile Picture
    293 on at

    I am having issues with this as well. My component has a gallery. Using the OnReset property I created two collections which I then use to populate the gallery and then manipulate the output. My gallery has text input fields and combo boxes. My intention is to update one of my collections with the OnChange property of the input controls with an UpdateIf(collection2, id = ThisItem.id, { prop: something})

     

    It works sometime but when I refresh both the component library or my canvas app, I get 2 errors foreach control

    1. Name isn't valid. '{0}' isn't recognized textcontrol1
    2. The function 'UpdateIf' has some invalid arguments. [its the reference to the collection that I created in OnReset that is causing the issue.]

    I thought  maybe if I reset the component it would resolve the error but that does not. I am not sure how to use collections in this situation.

     

  • KASCHN Profile Picture
    293 on at

    So, I think I found a resolution to this issue. You can create your collections in the OnReset which runs when the component is loaded on a screen or if you use the method Reset(myComponent). To resolve the errors, I added a "fake" icon button with visible = false and added the same ClearCollect statement i used in the OnReset to the OnSelect property.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 337 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 250

#3
Mohsin Ali Profile Picture

Mohsin Ali 225

Last 30 days Overall leaderboard