Search code examples
powerappspowerapps-formula

PowerApps interate through list updates


Short Version

Is there a way to update a single field in a collection/data source for all rows that meet a certain categorical criteria?

Background and Goal

I'm currently using PowerApps (SharePoint source) to maintain an inventory list for employees to locate items stored in bins. App is working great, but the next step is to give the users the ability to move all the items from one bin into another bin, ideally in a single scan. My theory being that you should be able to scan both bins, storing the details in separate text inputs or variables, and then patch all the items filtered to bin 1 with a new bin number, bin 2.

What I've Tried

I was able to patch a single item in a collection with this code: (don't mind the column name, I used D&D terms for my Sandbox testing grounds)

Patch(SandBoxList,First(Filter(SandBoxList,'Character Name' = "Juan Carlos")),{Class: Search_TextInput.Text})

I also tried to do the following, but ForAll() doesn't seem to play well with Patch() as Patch() wants to interact with a single record at a time:

ForAll(TestCollection,If(Class = "Monk",Patch(TestCollection,{Subclass:"None"},{Subclass: "Potato"})


Solution

  • In case anyone else comes across this, I found a YouTube video detailing exactly what I was trying to do:

    https://www.youtube.com/watch?v=0xZ4fMJbLvk

    It's a long one, but it'll walk you through the creation of the variables as well as how to iterate through based on a filter.