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

Collection not populating OnStart

Hello,

 

In hopes of improving performance, I have 3 cascading combo boxes that I tried to move their data to the App.OnStart method to cache and improve performance.  However the issue I face is that the collection isn't loading. I tested the app with the change from my mobile device and the drop down is blank.

 

Here is what my code originally looked like in the ComboBox.Items property:

AddColumns(Filter('[dbo].[JCJM]' JCCo = 1 && JobStatus = 1),"Jobs",Concatenate(Job, " - ", Description))

This works as expected, however when I changed this to App.OnStart:

ClearCollect(JobsCache,'[dbo].[JCJM]');

And then changed the Combox.Items property to:

AddColumns(Filter(JobsCache, JCCo = 1 && JobStatus = 1),"Jobs",Concatenate(Job, " - ", Description))

The combox drop down is blank.  After I made the change to the code, I saved, published and then tested it on my mobile device, but the drop down was blank.

 

Bonus question: Is there a better way to only return the 2 columns I need to create the calculated column rather than all columns plus the calculated column?  The code above is returning all columns which isn't what I need, I only need a Job and Description Column, plus the calculated column which is the concatenation of Job and Description. 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Collection not populating OnStart

@MikeAnderson 

Next suggestion is to move this out of the OnStart and into either a OnVisible of the main screen or behind a timer OnEnd action.  Sometimes the data is just not ready OnStart.  

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
5 REPLIES 5
Super User
Super User

Re: Collection not populating OnStart

@MikeAnderson 

First, have you taken a look at the JobsCache collection in the collection viewer?  Does it have values or is it empty?

Next, take a look at your Advanced Settings and see if the "Use non-blocking OnStart rule" is turned on or off.  You might consider adjusting that to see if the results change.

As for the bonus question- try changing your formula to this:

ClearCollect(JobsCache,
    ShowColumns('[dbo].[JCJM]', 
                           "Job", "Description"
) )

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
MikeAnderson
Level: Powered On

Re: Collection not populating OnStart

The JobsCache collection shows the columns are populated, but with no rows, which seems odd, since it's getting the columns, why not the rows?

3.png

 

The "Use non-blocking OnStart rule" was on, I set it to off and tested again. No dice.

 

BTW - THANK YOU for your suggestions and help!

Super User
Super User

Re: Collection not populating OnStart

@MikeAnderson 

Next suggestion is to move this out of the OnStart and into either a OnVisible of the main screen or behind a timer OnEnd action.  Sometimes the data is just not ready OnStart.  

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Highlighted
MikeAnderson
Level: Powered On

Re: Collection not populating OnStart

Thanks, your suggestions help me figure it out.  Turns out I missed that when I changed to the collection it changed the field that the combo box was using.  When I went to move the collection to the default screen.onvisible I happen to check the fields the combobox was using and discovered it was using a different field which is blank in the database.  I changed it back to the calculated field I created and tested and it work.

 

Sorry for taking your time, but I didn't know that PowerApps can change the field you select in a control!  So the collection is still in the App.OnStart and now working as I assumed.

Super User
Super User

Re: Collection not populating OnStart

@MikeAnderson 

That was going to be my next suggestion...check the drop down.  But wanted to make sure you were actually getting records in your collection first.

Glad you are moving to the next step now.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Top Kudoed Authors
Users Online
Currently online: 195 members 5,852 guests
Please welcome our newest community members: