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

Intermittent: gallery not showing records when filtered by variable set in app OnStart (3.19063.12)

I have a gallery, conected to a sharepoint list, which is filtered using a variable set in App.OnStart

Sometimes my gallery shows records, sometimes not.

 

How to reproduce

I have a sharepoint list 'Payment Requests' which has a text column called 'ApprovalStatus', I add records where some have ApprovalStatus ="Open". I generate the default three screen powerapp.

 

I add this to my app.onStart

Set(PaymentFilterStatus,"Open");

 

I then modify the galleries items property to :-

Filter('Payment Requests', ApprovalStatus = PaymentFilterStatus)

 

If I publish the app, then keep refreshing the app in the browser, sometimes it shows records in the gallery correctly, sometime it shows no records in the gallery. It's completely Intermittent.

 

Can someone explain this?

 

Thanks

 

12 REPLIES 12
Super User
Super User

Re: Intermittent: gallery not showing records when filtered by variable set in app OnStart (3.19063.12)

Check the Advanced settings for your app.  By default Asynchronous loading of the App is turned on.  That means that commands entered into OnStart are not guaranteed to finish before the app loads.  Taht can lead to the behavior you are seeing.  There are two options for fixing this issue.  One is to turn off the Use non-blocking OnStart rule but that may lead to slow loading of your app.  the other way to do it is to use a Splash screen that loads first and add the code from OnStart to something like the OnVisible property of the splash screen or a timer.  That way the app will load, but the screen that depends on the values that were in OnStart will be delayed,hopefully until the code you need to run is complete.  Here's what the rule looks like in advanced settings.

 

screenshot.png



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

Re: Intermittent: gallery not showing records when filtered by variable set in app OnStart (3.19063.12)

I have turned off 'Use non-blocking OnStart rule' but it is still happening.

 

Bizarrely, despite no changes to my code, it seems to be improving and happening less and less as the day goes on.

 

I have also had problems saving and publishing my apps today, receiving powerapps errors from the 'europe' powerapps servers saying things like 'unable to allocate storage'.

 

It feels like the cloud is moving under my feet.

Community Support Team
Community Support Team

Re: Intermittent: gallery not showing records when filtered by variable set in app OnStart (3.19063.12)

Hi @WMGDev ,

Based on the issue that you mentioned, I have made a test on my side, and don't have the issue that you mentioned.

 

Please consider set your PaymentFilterStatus variable within the OnVisible property of the first screen of your app rather than within OnStart property of the App control. Set the OnVisible property of the first screen of your app to following:

Set(PaymentFilterStatus,"Open")

Then re-publish your app, run your app again, then check if the issue is solved.

 

Also please consider turn off the "Improved app rendering (final validation)" option within Advanced settings of App settings of your app, then re-publish your app, check if the issue is fixed.

 

If the issue still exists, please consider re-create a new app based on your SP List, then try above solution again, check if the issue is solved.

 

Also please make sure the PaymentFilterStatus initialized properly within your app. You could consider add a Label control within the first screen of your app, set the Text property to following:

PaymentFilterStatus

check if the PaymentFilterStatus variable could be displayed properly.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
WMGDev
Level: Powered On

Re: Intermittent: gallery not showing records when filtered by variable set in app OnStart (3.19063.12)

Ok So this is driving me nuts.

Follow my steps to reproduce in the opening post.

Add one sharepoint record with 'ApprovalStatus' set to "Open"

Add one Sharepoint record with 'ApprovalStatus' set to "Pending"

 

Generate the threee screen app.

Modify App.OnStart to:

Set(PaymentFilterStatus,"Open")

Modify BrowseGallery1.Items to:

Filter('Payment Requests', ApprovalStatus = If(IsBlankOrError(PaymentFilterStatus),"Pending",PaymentFilterStatus))

 

Publish and keep refreshing the App in the browser.

Sometimes I see "Open" records

Sometimes I see "Pending" records

 

I have 'Use non-blocking OnStart rule" set to Off

 

I can reproduce this everytime

Here's a youtube video of my app displaying this behaviour

 

 

 

Super User
Super User

Re: Intermittent: gallery not showing records when filtered by variable set in app OnStart (3.19063.12)

One thought.  What happens if you change the IsBlankorError to just IsBlank()?  I'm wondering if you are seeing the pending records wehn there is an error rather than the OnStart not running or the variable actually being empty.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Highlighted
WMGDev
Level: Powered On

Re: Intermittent: gallery not showing records when filtered by variable set in app OnStart (3.19063.12)

Please consider set your PaymentFilterStatus variable within the OnVisible property of the first screen of your app rather than within OnStart property of the App control. Set the OnVisible property of the first screen of your app to following:

 

I've done that. Still happens.

 

 consider turn off the "Improved app rendering (final validation)"

 

I've done that, still happens


If the issue still exists, please consider re-create a new app based on your SP List, then try above solution again

 

Done that , still happens

 

You could consider add a Label control within the first screen of your app

 

Done that.

 

I've turned all experimental features off

 

I've created a brand new sharepoint list, brand new default 3 screen app. Made the two changes mentioned above, (I can initialise variable in onStart or  onVisible no difference) Still same issue.
Sometimes it takes up to ten browser refreshes to surface, but I can reproduce everytime.

 

If I replace the variable in the items filter with a string literal it works. The problem is with the variable.
It looks like the gallery is bringing data across, as if the variable is not set, then refreshing when variable is set, but sometimes that second refresh is not working??

WMGDev
Level: Powered On

Re: Intermittent: gallery not showing records when filtered by variable set in app OnStart (3.19063.12)

Ok Just to prove I am not nuts

Here is a short video (< 5 mins) that shows how to reproduce the problem, from scratch, from start to finish

I set the variable in onVisible:

Set(PaymentFilterStatus,"Open")

I set the filter to

Filter(FilterTest2, ApprovalStatus = If(IsBlankOrError(PaymentFilterStatus),"Pending",PaymentFilterStatus))

Stay with it till the end, it takes 27 browser refreshes for the issue to surface. Lol

But surface it does.

It is Intermittent, so sometime it goes wrong with less refreshes.

 

Full video showing how to reproduce

Super User
Super User

Re: Intermittent: gallery not showing records when filtered by variable set in app OnStart (3.19063.12)

Ok, I built a sample an was able to reproduce your results.  I also tested an alternate solution that I suggested in an earlier post, which seems to work.  Here's what I got to work.

Add a Splash Screen as the starting screen for the App.  Put a timer on the Splash Screen. You can set the timer to whatever you want.  I set mine to only 5 milliseconds. Add the Set(paymentFilterStatus, "Open") in onTimerStart on the Splash screen. In OnTimerEnd add a Navigate statement to go to your main screen where the Gallery is.  I also added a Navigate() to go to a second screen and then back in the app. Unless I did something to set PaymentFilterStatus to pending it always opened up filtered on "Open".  The one side effect was that the splash screen flashed up everytime I pressed F5 before going to the main screen.  But in general users won't press F5, they will just navigate between screens in the App.

 

Using this setup I was unable to get the Gallery filter to break like I could hitting F5 without the Splash screen.

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



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

Re: Intermittent: gallery not showing records when filtered by variable set in app OnStart (3.19063.12)

Thank you, Thank you For confirming I'm not going crazy.

What seems to be happening is:

Variable initialization seems to be asynchronous even if you do it in onVisible !

Therefore:
The Gallery makes a call to the datasource before the variable is intiallized !

i.e. the variable 'IsBlank'. The variable then gets initialized which makes the gallery refresh the datasource, except this refresh does not  always happen, caching maybe? It's as if the varible initialization is not always posting an onChanged event, or the gallery is not always refreshing when it picks up this onChanged!

 

Two ways round it.

1. Do as you suggest, initialise all your varibles in a splash screen, timer type setup

2. Change gallery items to something like

Filter(FilterTest2, ApprovalStatus = If(IsBlank(PaymentFilterStatus),"Open", PaymentFilterStatus))

This behaviour seems absolutely nuts

It leads to intermitent, inconsitent behaviour from PowerApps

 

Awful

Helpful resources

Announcements
firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

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

Top Kudoed Authors
Users Online
Currently online: 89 members 3,581 guests
Please welcome our newest community members: