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 / Iterating through a ga...
Power Apps
Answered

Iterating through a gallery

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

I am new to Power Apps, and have unfortunately kind of been thrown into the weeds to fix a broken app. I have a gallery of products pulled from a dataverse table. There is a text input used to filter the gallery down to just what the employee wants to see out of the many thousands of rows. The gallery is set to hidden until the user types something into the text input, then it returns only those rows that match one of the columns (org_id). This all works as it should. The issue I have is updating the table when a user makes a change. For example, the user filters by a specific org_id which returns 5 products (same org_id, different circuit_id or name, etc.). One of the options is a Notes text input. When the user modifies the text input on one or more of the returned gallery items, and clicks a Save Changes button, I would like it to patch the table. My thought was a simple if statement for each and, if the notes field on the app does not match the notes column in the table, patch. This works for me when there is a single item in the gallery:

 

 

 

	Patch (
		Table1S,
		First (
			Filter (
				Table1S, stripped_name = Circuit_2.Text
			)
		),
		{
			JLoTestColumn: Circuit_2.Text
		}
	);

 

 

 

The problem is I cannot seem to iterate through the gallery if there are multiple items. For example, something simple like this only returns the last item in the gallery:

 

 

 

 ForAll(
 Gallery1_4.AllItems,
 Notify(Circuit_2.Text)
 );

 

 

 

I do see a ThisRecord option, but I get the same result. I have been searching online, and most of what I come across looks like people are writing to an internal collection and updating from there, but that seems really cumbersome, especially if the filter only returns a single record. Is there a best practice (hopefully easy) way of iterating through the gallery, regardless of number of items returned, and updating the table for records that have changed?

Categories:
I have the same question (0)
  • Verified answer
    CarlosFigueira Profile Picture
    Microsoft Employee on at

    You're on the right track. Your ForAll(..., Notify()) expression isn't working because Notify currently only shows one message, so you are not seeing all of them. But it should work with an expression similar to this one:

     

    ForAll(
     Gallery1_4.AllItems,
     If(
     ThisRecord.Circuit_2.Text <> ThisRecord.JLoTestColumn,
     Patch(Table1S, ThisRecord, { JLoTestColumn: ThisRecord.Circuit_2.Text })))

     

    Here's an example of an app that uses something similar:

    ForumThread2185130.gif

    Hope this helps!

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thanks for the nudge. I will try this out.

     

    Edit: That worked perfectly, thank you very much.

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

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 316 Most Valuable Professional

#2
11manish Profile Picture

11manish 242

#3
Valantis Profile Picture

Valantis 198

Last 30 days Overall leaderboard