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 / ForAll Patch a Collect...
Power Apps
Answered

ForAll Patch a Collection Gallery if a toggle is marked as true (Editable Tables)

(0) ShareShare
ReportReport
Posted on by 301

Hi,

 

Im trying to build an editable table similar to this

https://matthewdevaney.com/power-apps-excel-style-editable-table-part-1/

However im stuck on building a save button that looks for all the items in a gallery and patches the collection of items if the toggle has changed.

The code i was given in the tutorial was this, it differs from mine by i dont wish to upload to sharepoint collection i just want to update the current collection and i just cant get the code right, see my code below

 

 

ForAll(
 Filter(
 gal_EditableTable.AllItems,
 tog_isChanged.Value
 ) As ChangedRows,
 Patch(colUpdates,
 Defaults(colUpdates), {
 ID: ChangedRows.ID,
 ItemNumber: ChangedRows.txt_ItemNumber.Text,
 Description: ChangedRows.txt_Description.Text,
 Quantity: Value(ChangedRows.txt_Quantity.Text),
 Location: ChangedRows.txt_Location.Text
 })
);

// Update SharePoint with new values
Patch('Inventory Count', colUpdates);
Clear(colUpdates);

// Return gallery to view mode
Set(varGalleryMode, Blank());

 

 



IGNORE ITS THE CODE BELOW

 

ForAll(
 Filter(
 Gallery.AllItems,
 tog_isChanged.Value
 ) As ChangedRows,
 Patch(colDATA,ChangedRows,
 {
 GID:GID,
 Sample: ChangedRows.GalSampleID_1.Text,
 FROM: ChangedRows.GalFromM_1.Text,
 TO: ChangedRows.GalToM_1.Text,
 
 
 }
 )
);

 

 

 

I know im on the right track..

Categories:
I have the same question (0)
  • Verified answer
    RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @ShaneITAutomate 

    Thing is...you're ForAll is the key to this.  Instead of looking at it as a For/Loop, use it as it was designed...to return a Table.

     

    You mention that didn't want to "upload to SharePoint collection"... I'm not sure what you mean by that, but you were certainly attempting to update your Inventory Count list in that formula.

     

    Please consider changing your Formula to the following:

    // Update SharePoint with new values
    Collect('Inventory Count', 
     ForAll(Filter(gal_EditableTable.AllItems, tog_isChanged.Value) As _item,
     {
     ID: _item.ID
     ItemNumber: _item.txt_ItemNumber.Text,
     Description: _item.txt_Description.Text,
     Quantity: Value(_item.txt_Quantity.Text),
     Location: _item.txt_Location.Text
     }
     )
    )
     
    // Return gallery to view mode ??
    Set(varGalleryMode, Blank());

    In the above, we use the ForAll to return a Table of the records based on the Filter of the Gallery where the toggle is true.   This creates a record table that we can just push back to the Collect function to the datasource.  Collect will handle the rest - no collections needed.

     

    I hope this is helpful for you.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 893

#2
Valantis Profile Picture

Valantis 571

#3
11manish Profile Picture

11manish 482

Last 30 days Overall leaderboard