Showing results for 
Search instead for 
Did you mean: 
Impactful Individual
Impactful Individual

How do you trigger Gallery.Items recomputation?


Please be so kind as to read my full post before responding.
Thank you for your consideration.

In one PowerApp I have built something akin to a multi-select picklist using two Galleries.
The purpose is to assign Orders to Delivieres.
Orders are collected locally into LocalOrders upon App.OnStart or RefreshButton.OnSelect.

To upper Gallery (containing the Orders assigned to the current delivery) has Items

Filter(LocalOrders, !IsBlank(kk_warehouse_delivery_id), kk_warehouse_delivery_id.kk_warehouse_deliveryid=selectedDelivery.kk_warehouse_deliveryid)

and, inside the template, UnassignButton.OnSelect

Unrelate(LookUp([@'Auslieferungen (WA)'], kk_warehouse_deliveryid=selectedDelivery.kk_warehouse_deliveryid).'Aufträge (WA)', LookUp([@'Aufträge (WA)'], kk_warehouse_orderid=ThisItem.kk_warehouse_orderid));
Patch(LocalOrders, {kk_warehouse_orderid: ThisItem.kk_warehouse_orderid}, {
    kk_warehouse_delivery_id: Blank()

as formulae of the Trash icon.
The lower Gallery (containing the unassigned Orders) has Items

Filter(LocalAuftraege, IsBlank(kk_warehouse_delivery_id))

and, inside the template, AssignButton.OnSelect

Relate(LookUp([@'Auslieferungen (WA)'], kk_warehouse_deliveryid=selectedDelivery.kk_warehouse_deliveryid).'Aufträge (WA)', LookUp([@'Aufträge (WA)'], kk_warehouse_orderid=ThisItem.kk_warehouse_orderid));
Patch(LocalAuftraege, {kk_warehouse_orderid: ThisItem.kk_warehouse_orderid}, {
    kk_warehouse_delivery_id: selectedDelivery

as formula of the + Icon
Relate/Unrelate takes care of the LookUp fields/Relational Data table on the CRM side.
On the local side I use Patch.

The UnassignButton does everything I expect it to do, setting the lookup field to Blank in the CRM and in my local collection.
Also both galleries seem to always refresh Items whenever I use this UnassignButton.

However, the AssignButton appears to sometimes work, and sometimes do nothing.
A closer look tells me that on the data level setting the CRM and in my local collection both work properly.
But, the galleries don't update and still show me (wrong) Items in both galleries.
It appears as if the recomputation of both gallery Items isn't triggered upon setting the relevant lookup fields in my local collection LocalOrders.
Exiting the screen and reloading the delivery properly refreshes both galleries, which then show the previously reassigned orders in the correct galleries.

My questions:

  1. Can I manually trigger the recomputation of Gallery.Items?
  2. Why does my UnassignButton and setting the lookup field to Blank apparently trigger a recomputation of Gallery.Items while setting to a nonblank value does not?

Last test with:

App ID: 8200a3f3-30fd-44f9-b3b7-0c9e0f803c50
Session ID: 21a66c2e-a2f6-472c-bffc-a84600ce0745
PowerApps 3.19081.26

Thank you,

Impactful Individual
Impactful Individual

Re: How do you trigger Gallery.Items recomputation?


I have an inefficient workaround using ClearCollect but this still doesn't really answer my questions.


Helper V
Helper V

Re: How do you trigger Gallery.Items recomputation?

Can you share your workaround?

Impactful Individual
Impactful Individual

Re: How do you trigger Gallery.Items recomputation?

Hi @Lisabel0

My workaround, obviously copy & pasted using the names etc of my own DataSources and entities etc:

  1. Add an invisible (dummy) button LieferungCollect to the Screen, with OnSelect set to
    Refresh([@'Aufträge (WA)']);
            ClearCollect(LocalAssigned, Filter([@'Aufträge (WA)'], kk_warehouse_delivery_id.kk_warehouse_deliveryid=selectedDelivery.kk_warehouse_deliveryid)),
        ClearCollect(LocalUnassigned, Filter([@'Aufträge (WA)'], IsBlank(kk_warehouse_delivery_id)))
  2. Change the Items of the AssignedGallery of assigned items/orders to
  3. Change the Items of the UnassignedGallery of unassigned items/orders to
  4. Add Select(LieferungCollect) in all relevant control events, i.e.
    AssignButton.OnSelect in the UnassignedGallery Template:
    Relate(LookUp([@'Auslieferungen (WA)'], kk_warehouse_deliveryid=selectedDelivery.kk_warehouse_deliveryid).'Aufträge (WA)', LookUp([@'Aufträge (WA)'], kk_warehouse_orderid=itemId));
    UnassignButton.OnSelect in the AssignedGallery Template:
    Unrelate(LookUp([@'Auslieferungen (WA)'], kk_warehouse_deliveryid=selectedDelivery.kk_warehouse_deliveryid).'Aufträge (WA)', LookUp([@'Aufträge (WA)'], kk_warehouse_orderid=itemId));

Essentially I use local Collections for the Items of both galleries and re-collect these collections upon loading and after every change to the relational data.

I hope this helps a bit.
Good luck,

Helpful resources

Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.


Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Tech Marathon

Maratón de Soluciones de Negocio Microsoft

Una semana de contenido con +100 sesiones educativas, consultorios, +10 workshops Premium, Hackaton, EXPO, Networking Hall y mucho más!

Top Solution Authors
Top Kudoed Authors
Users online (9,815)