cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
seadude
Memorable Member
Memorable Member

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
RakeshPandey
Helper I
Helper I

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.

v-yutliu-msft
Community Support
Community Support

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.
yashag2255
Dual Super User II
Dual Super User II

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
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Top Solution Authors
Top Kudoed Authors
Users online (50,311)