Adventures with Power Apps: Moving Items Between Galleries

I was recently inspired by Power Apps Reorder Gallery Items – April Dunnam – SharePoint Siren, an “oldie but goodie” article by April Dunnam.

I decided to build my own implementation.

I wanted my version to not have a strong dependency on if there was an n-1 or n+1 item in the list, so I modified accordingly.

Figure 1 – The finished product

I used two collections, colAvailableItems and colSelectedItems and two galleries, galAvailableItems and galSelectedItems.

The items in the collection are made up of two properties: Ordinal and Name.

The galAvailableItems is sorted by name, while galSelectedItems is sorted by Ordinal.

The code for moving items from galAvailableItems to galSelectedItems is as follows:

The code for moving items from galSelectedItems to galAvailableItems is as follows:

The ForAll is what renumbers the items in the collection to assure there are no gaps in the Ordinal.

The code for moving an item up in the galSelectedItems is as follows:

The code for moving an item down in galSelectedItems is as follows:

You can download the complete solution at https://mattruma.com/wp-content/uploads/2024/03/GallerySolutionMoveBetweenLists_1_0_0_1.zip.


Discover more from Matt Ruma

Subscribe to get the latest posts sent to your email.

Leave a Reply

Your email address will not be published. Required fields are marked *