cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Super User
Super User

COMPONENTS: Create a Collection in a Component?

Hello,

 

I want to create a reusable tracking component. Click a button, collect a timestamp, click the button again, collect another timestamp, etc.

 

I don't know how to approach this problem since "...PowerApps doesn't support collections in components".

 

Is there a way to:

  • Reuse the component across different app screens
  • Collect these timestamps from each screen/component to the same Collection in the App

Would I use a Custom Output Property here and variables?

 

@yashag2255, @RandyHayes 

3 REPLIES 3
Highlighted
Helper I
Helper I

Re: COMPONENTS: Create a Collection in a Component?

I created a Component and inside that added a button. I wrote "Collect(TimeStamp,Now())" on the OnSelect method of the button. Also I used the components in multiple screen and it is working. I also exported the component and imported in another App and it is working. May be you try using collect command in your component.

Highlighted
Community Support
Community Support

Re: COMPONENTS: Create a Collection in a Component?

Hi @seadude ,

Do you want to set a control's OnSelect inside component to Collect collection?

I've made a similar test and found that it is feasible.

Please note that component is an experimental control, so its function is improving.

Once in a while, its function will update. The doc that you listed wrote six months ago, some new functions may not update.

 

Here's my test for your reference:

1)Create a component, set a button 's OnSelect:

Collect(a,{id:Now()})814.PNG

 

2)Insert this component in screen1 and screen28141.PNG

 

8142.PNG

 

3)Set a gallery's Items to this collection: a

4)Run this app

If I click the button in screen1 and click the button is screen2, the collection will update successfully.8143.PNG

 

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted
Dual Super User III
Dual Super User III

Re: COMPONENTS: Create a Collection in a Component?

Hey @seadude 

 

You can try to use the below expression on the OnSelect property of the button inside the component. I carried a test on my side and this works fine. Please refer to below screenshots:
 
Expression Used:
Collect(MyCollection,{Title:Concatenate("Test",Text(CountRows(MyCollection)+1)),TimeStamp: Now()})
 
The highlighted part collects the timestamp.
 
When imported on multiple screens, this will point to the same collection.p.png

 

m.png

 

Hope this Helps!
 
If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

Helpful resources

Announcements
August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

secondImage

Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

secondImage

Super Users Coming in August

We are excited for the next Super User season.

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (8,209)