web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Intermittent: gallery ...
Power Apps
Unanswered

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

(0) ShareShare
ReportReport
Posted on by 43

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

 

Categories:
  • Pstork1 Profile Picture
    69,661 Most Valuable Professional on at

    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

  • WMGDev Profile Picture
    43 on at

    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.

  • v-xida-msft Profile Picture
    Microsoft Employee on at

    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,

  • WMGDev Profile Picture
    43 on at

    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

     

     

     

  • Pstork1 Profile Picture
    69,661 Most Valuable Professional on at

    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.

  • WMGDev Profile Picture
    43 on at

    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 Profile Picture
    43 on at

    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

  • Pstork1 Profile Picture
    69,661 Most Valuable Professional on at

    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.

  • WMGDev Profile Picture
    43 on at

    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

  • Pstork1 Profile Picture
    69,661 Most Valuable Professional on at

    That's one of the problems inherent in a declarative environment as opposed to a procedural one.  You don't control the order that things happen in.  Usually its not a problem, but when it is its a really big problem.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 396 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 323

#3
WarrenBelz Profile Picture

WarrenBelz 193 Most Valuable Professional

Last 30 days Overall leaderboard