Skip to main content

Notifications

Community site session details

Community site session details

Session Id : eSYNBXyn1HJ1NESChGM8le
Power Apps - Building Power Apps
Answered

Loop through Gallery with textboxes and save it item in collection

Like (2) ShareShare
ReportReport
Posted on 27 Jan 2022 22:02:37 by 578

I have a Gallery which Items property is a collection. Each collection item is represented in a Textbox:

Gallery.jpg

Then there are a couple textboxes that are empty by default, and will only be filled later, and other textboxes may be updated. I need to loop through the entire Gallery, ClearCollect the original collection, and recreated with the new textboxes in the collection. I created a button, and OnSelect I added:

 

ClearCollect(
 ExcellData, //Collection I'm using
 ForAll(
 ImpactSummaryFields.AllItems As Items, //This is the Gallery
 {
 State: Items.StateField.Text,
 County: Items.CountyField.Text,
 FIP: Items.FIPSField.Text,
 MFN: Items.MapFileNameField.Text,
 Crop: Items.CropField.Text,
 SubCounty: Items.SubCountyField.Text,
 CurrentAcres: Items.CurrentAcresField.Text,
 ProposedAcres: Items.ProposedAcresField.Text,
 Percent: Items.PercentageCounty.Text,
 CurrentFSN: Items.CurrentNoFSN.Text,
 ProposedFSN: Items.ProposedNoFSN.Text,
 ChangedFSN: Items.ChangeNoFSN.Text,
 CurrentRate: Items.CurrentRate.Text,
 ProposedRate: Items.ProposedRate.Text,
 }
 )
);

When I click on the button the updates are not added, and some of the rows are removed. What am I doing wrong? Is this even possible?

 

Thanks.

  • Verified answer
    WarrenBelz Profile Picture
    146,932 Most Valuable Professional on 29 Jan 2022 at 21:42:45
    Re: Loop through Gallery with textboxes and save it item in collection

    @emfuentes27 ,

    You do not need to - all the gallery fields will be collected and available for reference.

     

    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

     

  • emfuentes27 Profile Picture
    578 on 29 Jan 2022 at 17:43:17
    Re: Loop through Gallery with textboxes and save it item in collection

    Thanks @WarrenBelz , but, how do I define whick each of the properties? E.g. State, County, etc. I intend to reuse the data, so I need it we'll defined.

  • emfuentes27 Profile Picture
    578 on 29 Jan 2022 at 17:41:05
    Re: Loop through Gallery with textboxes and save it item in collection

    Thanks @StalinPonnusamy , but there is no Unique ID. Actually, some of the rows just differ in a couple of cell. 

  • StalinPonnusamy Profile Picture
    Super User 2024 Season 1 on 27 Jan 2022 at 22:51:37
    Re: Loop through Gallery with textboxes and save it item in collection

    Hi @emfuentes27 

     

    I assume you have a Unique ID that represents each row. In my example, I have ID and renaming for name conflict.

     

    ForAll(
     RenameColumns(
     ImpactSummaryFields.AllItems,
     "ID",
     "NewID"
     ),
     Patch(
     ExcellData,
     {
     ID: NewID,
     State: StateField.Text,
     County: CountyField.Text
    //Other fields
     }
     )
    )

     

  • WarrenBelz Profile Picture
    146,932 Most Valuable Professional on 27 Jan 2022 at 22:43:43
    Re: Loop through Gallery with textboxes and save it item in collection

    Hi @emfuentes27 ,

    Assuming you want all the fields in the Gallery

    ClearCollect(
     ExcellData,
     ImpactSummaryFields.AllItems
    )

     

    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

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Power Apps - Building Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 78 Most Valuable Professional

#2
MS.Ragavendar Profile Picture

MS.Ragavendar 49

#3
mmbr1606 Profile Picture

mmbr1606 41 Super User 2025 Season 1

Overall leaderboard
Loading started