cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Clxmxnt25
Frequent Visitor

OnVisible ClearCollect/UpdateContext is not Populating Collection If you navigate and return to the screen

As the title states, my collection is coming up empty/blank after I renavigate to the same screen. I am using a gallery to display the data. It only shows up when you first load up the app or if you wait some time and re-navigate.

 

The only error message I get is not divisible by zero error when it fails to get the total count.

 

My OnVisible Tag looks like this(After changing from ClearCollect and Set):

UpdateContext({
    MyQTCollection:
    SortByColumns(
        quoteCollection,
        "Modified",
        SortOrder.Descending
    )
});
Concurrent(
    UpdateContext({
        InTotalItemsCountQT:
        CountRows(MyQTCollection)
    }),
    UpdateContext({
        InGalleryHeightQT:
        QuotesGallery.Width
    }),
    UpdateContext({
        InGalleryTemplateHeightQT:
        QuotesGallery.TemplateWidth / 4
    }),
    UpdateContext({
        varResetQT:
        GUID()
    })
)

Galleries "Item" Formula (Works when the values are displayed);

If(
    QTGalleryPagination.OutCurrentPage = QTGalleryPagination.OutTotalPages,
    LastN(
        FirstN(
            Search(MyQTCollection, QTGallerySearch.Text, "Title", "QuoteNotes", "QuoteNumber", "QuoteDescription"),
            QTGalleryPagination.OutPageCounter
        ),
        (InTotalItemsCountQT - (QTGalleryPagination.OutPageCounter - QTGalleryPagination.OutItemsPerPage))
    ),
    LastN(
        FirstN(
            Search(MyQTCollection, QTGallerySearch.Text, "Title", "QuoteNotes", "QuoteNumber", "QuoteDescription"),
            QTGalleryPagination.OutPageCounter
        ),
        QTGalleryPagination.OutItemsPerPage
    )
)

I am utilizing a pagination component I found elsewhere. It's worked for me for the years and still works in the old version of the app. After switching to UpdateContext, I see the values in the variables view but somehow it's not showing anything in the gallery.

 

I'm not sure if it's because of the new update but the same thing is happening with the rest of my screens. I'm using the same formulas on the old version and that works perfectly with no issues. My Data row limit is set to 2000. There are currently 5 items in the list it's pulling from so that does not seem to be the problem. I'm not sure why this is happening now. I have changed upcoming feature settings (enabled/disabled), saved and restarted Power Apps, cleared cache and cookies, and am still getting the same problem. I've also tried it on a different device and it's still an issue.

 

What it looks like with the issue.

Clxmxnt25_0-1655935039456.png

If you'd like more information please let me know.

1 ACCEPTED SOLUTION

Accepted Solutions
Clxmxnt25
Frequent Visitor

Just in case anyone is wondering about the solution with the layouts. You have to go through every component and set the absolute "Width/Height" and not the Flexible versions

View solution in original post

6 REPLIES 6
WarrenBelz
Super User
Super User

Hi @Clxmxnt25 ,

Firstly, I would need a model to look at the second bit, but you mentioned that it broke with UpdateContext() which is a Variable (which can be a table, but is mainly designed for single values and records) - why change from a Collection which is far more flexible and designed to hold tables ? As a test, go back to ClearCollect at the top and see if that fixes it.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Visit my blog Practical Power Apps

I get the same issue with both UpdateContext and ClearCollect. I only switch to UpdateContext to test whether it'd be different.

This is the data model:

Clxmxnt25_0-1655943050757.png

 

@Clxmxnt25 ,

I was hoping to help with a simple solution based on your post statement After switching to UpdateContext, I see the values in the variables view but somehow it's not showing anything in the gallery, but this is not the case. As I mentioned, I would need to build a model to even attempt to duplicate an error in what initially seems valid code, something I presently do not have the time to do. I will however make an observation on a Variable where the structure is not specified and I believe the root cause lies here

QTGalleryPagination.OutCurrentPage = QTGalleryPagination.OutTotalPages,

So I did some more playing around and testing and found out that it was due to the width of the gallery. It is nested in a couple of horizontal/vertical layouts which causes the `InGalleryHeightQT` to return 0

 

Clxmxnt25_0-1656023550775.png

I changed the values in the layout controls to ignore flexible width and use the standard, which worked for a bit but later reverted to a 0 InGalleryHeightQT. I will try to record a video later for clarity. This is progress at least.

 

As a last resort, I'm thinking of removing the layout controls and using standard width with formulas. What are your thoughts?

Hi @Clxmxnt25 ,

I am not big into dynamic controls other than shifting things around the screen and gallery heights based on the content number, so I am probably the wrong person to ask, however I always use a base rule of keep it as simple as possible, so you could be correct.

Clxmxnt25
Frequent Visitor

Just in case anyone is wondering about the solution with the layouts. You have to go through every component and set the absolute "Width/Height" and not the Flexible versions

Helpful resources

Announcements
Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on August 17, 2022 at 8am PDT.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Users online (3,492)