cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
NickAdams1975
Level: Powered On

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
Super User
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.
Super User
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!
4 REPLIES 4
Super User
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.
Super User
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!
NickAdams1975
Level: Powered On

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

Super User
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!