cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
NickAdams1975
Regular Visitor

Problem creating a basic collection

All I am trying to do is follow the beginners tutorial document called,

 

"Author a basic formula that uses tables and records in a PowerApps canvas app"

 

I just want to step through this little test and create a collection as a formula.

 

So in 'Screen 1' of a the most basic canvas I enter:

 

Collect(collectMyFirstCollection, {Name: "Jeff", FavoriteColor:"Blue"}, {Name: "Chewy", FavoriteColor: "Red"})

 

This seems to create collectMyFirstCollection 

 

But when I 'View Collections' in PowerApp, whilst the field headings are there, there are no records. Thus I cannot even run a simple formula on (for example) the most simple Text object and give it a title of "Blue" from the collection.

 

I am obviously missing something basic and fundamental. Could someone help please?

 

Many thanks,

 

Nick

2 ACCEPTED SOLUTIONS

Accepted Solutions
Dual Super User
Dual Super User

Re: Problem creating a basic collection

Your formula is correct.  But where are you entereing the formula?  Add a button to Screen 1 and put the formula in the onSelect method of the button.  Then when you run your app you can press the button to create your collection.  You could also put it in the OnStart method of the app itself.  When you run the app it will create the collection.

 

I would however suggest in this case that you use ClearCollect instead of Collect.  Each time you run Collect it will add the records specified to the collection.  ClearCollect deletes the collection first. To update existing records in a collection use Patch



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

Dual Super User
Dual Super User

Re: Problem creating a basic collection

Hi @NickAdams1975 

 

I guess you are seeing this issue because you have put the function to collect this collection on "OnVisible" property of your screen, and while we are in edit mode, the "onscreen" doesn't get executed when we play the app. This will work if you set a navigation from one screen to other, so when you are getting navigated, the "On Visible" will get executed.
 
As a workaround, you can use a temporary button and put the formula on "OnSelect" property while testing your app and create the collection through it. This is a simple edit mode restriction.
 
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!

View solution in original post

4 REPLIES 4
Dual Super User
Dual Super User

Re: Problem creating a basic collection

Your formula is correct.  But where are you entereing the formula?  Add a button to Screen 1 and put the formula in the onSelect method of the button.  Then when you run your app you can press the button to create your collection.  You could also put it in the OnStart method of the app itself.  When you run the app it will create the collection.

 

I would however suggest in this case that you use ClearCollect instead of Collect.  Each time you run Collect it will add the records specified to the collection.  ClearCollect deletes the collection first. To update existing records in a collection use Patch



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

Dual Super User
Dual Super User

Re: Problem creating a basic collection

Hi @NickAdams1975 

 

I guess you are seeing this issue because you have put the function to collect this collection on "OnVisible" property of your screen, and while we are in edit mode, the "onscreen" doesn't get executed when we play the app. This will work if you set a navigation from one screen to other, so when you are getting navigated, the "On Visible" will get executed.
 
As a workaround, you can use a temporary button and put the formula on "OnSelect" property while testing your app and create the collection through it. This is a simple edit mode restriction.
 
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!

View solution in original post

NickAdams1975
Regular Visitor

Re: Problem creating a basic collection

I think I understand my issue. I thinkthe formulas are correct but I am not understanding how to save and refresh the app appropriately.

 

So when I closed the web browser and came back to it all it worked.

 

I don't understand this though as my App preview will not work and holding down the ALT key will not work until I save the close down the browser.

 

Do you have any tips on the process I should follow to make my app work. I assumed that it would work as soon as I entered formulas but it doesn't on mine!

 

Thanks,

 

Nick

Dual Super User
Dual Super User

Re: Problem creating a basic collection

Hi @NickAdams1975 

 

You can put the code on App control and select the property "OnStart", this will create the collection once whenever you app is started.
MicrosoftTeams-image (131).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
MBAS Gallery 2020

MBAS Gallery 2020

Watch Microsoft Business Applications Summit sessions on-demand.

firstImage

New Ranks and Rank Icons released on April 21!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power Apps Community!

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