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 Bulk upda...
Power Apps
Answered

ForALL/Patch Bulk update a Single value into all records

(0) ShareShare
ReportReport
Posted on by 127

Hello All!

 

This might have posted before, but I'd have to comb the whole internet to find the exact problem I'm having. I this this is a syntax issue? I don't know.

I have a gallery (GalSelect) for selecting multiple records. The selected records go into a collection (colSelect). Then I have a another gallery (galEdit) displaying the selected records (displaying the collection, colSelect, data), like a shopping cart. The user needs to assign a location to the selected records. The can select the location from a combobox, "Combobox1"

 

GalSelect - select multiple items 

colCalSelect - puts selected items in a collection

GalEdit - Displays selected items for editing/updating.

Combobox1 - Holds the value to be updated.

"PowerApps Submit" - Sharepoint List source to be patched.

"Courtroom" - name of column in both the collection and the Sharepoint list for patching.

 

I can't get the patch to work. The collection columns are not the same as the column names in "Power Apps Submit", the sharepoint list to be patched. So, I don't know how to write a Patch for just one column of the collection

 

Here's what I have so far:
ForAll(colCalSelect, Patch( 'PowerApps Submit', Defaults( 'PowerApps Submit', {Courtroom} = Courtroom[@colCalSelect])))

 

Thank you so much in advance!

Categories:
I have the same question (0)
  • v-xiaochen-msft Profile Picture
    Microsoft Employee on at

    Hi @Dianez ,

     

    Please try this

    ForAll(colCalSelect As temp, Patch( 'PowerApps Submit', Defaults( 'PowerApps Submit'), {Courtroom:temp.Courtroom}))

     

    Best Regards,

    Wearsky

  • Marshal_Jerome Profile Picture
    88 on at

    HI @Dianez 

    Please try like below example, blow code will take all records from CurrerntTransLine Collection and inserting to TransLine table.   (TransLine  is a table in local SQL database).

     

    ForAll(
             CurrentTransLine,
             Patch(
                    TransLine,
                    Defaults(TransLine),
                   {StoreNumber: loggedinstore},
                   {TransactionNumber: Text(NewTransNumber)},
                   {LineID: LineId},
                   {ItemNumber: ItemNumber},
                   {Barcode: Barcode}
          )
    );

  • Dianez Profile Picture
    127 on at

    @Marshal_Jerome  and @v-xiaochen-msft 

     

    I see why there is an error. The column in the collection is a text column. The column in the Sharepoint list is a Lookup Column. When I did a test patch by adding a text column to SharePoint, I was able to code it in, even though the column names are different.

     

    ForAll(
    colCalSelect,
    Patch(
    'PowerApps Submit',
    Defaults('PowerApps Submit'),
    {testPatch: Courtroom}
    )
    )

     

    How can I patch text data to a lookup column in Sharepoint?

     

  • v-xiaochen-msft Profile Picture
    Microsoft Employee on at

    Hi @Dianez ,

     

    Is 'testPatch' a lookup column?

    If my guess is right, please try this:

    ForAll(
    colCalSelect,
    Patch(
    'PowerApps Submit',
    Defaults('PowerApps Submit'),
    {testPatch: {Id:LookUp(datasource,Column=Courtroom).ID,Value:Courtroom}}
    )
    )

    //Column is the related column name from the lookup list.

     

    Best Regards,

    Wearsky

  • Dianez Profile Picture
    127 on at

    @v-xiaochen-msft 

     

    Thank you so much for your response! A few things have happened since I posted that question, but I'll try and be brief. Essentially, the way I was going about it seemed to be a bit convoluted. Multiple galleries, etc. So, I built an editable grid gallery.  I did try and use the formula you suggested almost exactly as it is written and I got the error. 

     

    • Collection is colSelcted
    • Datasource is BorrowedCourtroom
    • Courtroom is column in datasource
    • courtroombulk is combobox with the column data
    • the Gallery control is data source is colGrid from a collection called colGrid. Collect(colGrid, borrowedcalendar)

     

     

    I wrote: 

    ForAll ( colSelected, Patch( BorrowedCalendar, Defaults( BorrowedCalendar), {Courtroom: {Value: CourtroomBulk.Selected.Value, Id: 1}}))

     

    Dianez_0-1696959356338.png

     

    I'm a bit lost on that one.  Secondly, with the editable grid gallery, I now need to update, instead of creating a new record. I was just hoping I could get this to work, and would lead to a solution to update an existing lookup column.

     

    UpdateIf(colGrid, ThisRecord in colSelected, {Courtroom: { Id: LookUp(BorrowedCalendar, Courtroom = Courtroom).ID, Value: CourtroomBulk.Selected.Value}})

     

    I get the "cannot compare a record with a record" error (red squiggle) under the equal sign.

     

    Dianez_3-1696960784065.png

     

     

     

     

     

     

  • Dianez Profile Picture
    127 on at

    @v-xiaochen-msft @Marshal_Jerome 

    update from the last post 35 minutes ago.

     

    This worked for creating a new record!!

     

    ForAll(colSelected, Patch(BorrowedCalendar,Defaults(BorrowedCalendar), {Courtroom: {Value: CourtroomBulk.Selected.Value, Id: CourtroomBulk.Selected.Id}}))

     

    How do I change this to update existing records?

     

    Thanks in advance!

     

  • Marshal_Jerome Profile Picture
    88 on at

    Replace the dafaults(BorrowedCalander) by your filter criteria as below. 

     

    LookUp( '[dbo].[Orders1]', OrderId = A[@OrderId]  (Change Table name and column name as per your table)

  • Dianez Profile Picture
    127 on at

    Sorry, but that didn't work. I'm not sure I understood the which data source goes where in this example. Thank you for getting back to me.

     

    I thought I got it to work, but I didn't. I didn't get any error, though. It updated, then the update disappeared. So weird.

     

    UpdateIf (colGrid, ThisRecord in colSelected, {Courtroom: {Value: CourtroomBulk.Selected.Value, Id: CourtroomBulk.Selected.Id}});Clear(colSelected);Reset(CheckboxAll)

     

    Updateif ( "Collection in the gallery", ThisRecord in "Collection with selected items", { "Column name in collection connected to gallery": Value: "Control.Selected.Value", Id: "Control.Selected.Id" }

     

    For lookup columns, both the value: and the Id:  need to be provided. Id has to be written with uppercase "I" and lowercase "d". no exceptions.

     

    https://rezadorrani.com/index.php/2020/05/04/power-apps-patch-function-with-sharepoint/

     

     

  • Verified answer
    Dianez Profile Picture
    127 on at

    @v-xiaochen-msft @Marshal_Jerome 

     

    Soooo, I learned a lot today! There are lots of ways to do this and I was lost trying to follow several different tutorials, picking pieces of information I needed, and trying to use it in this app. Anyway, I hope this will help someone

     

    Dianez_0-1697135399241.png

     

     

    I had to change my app a bit It works, but I lost the Select All check box. Basically the gallery data was coming from a collection. The collection was my data source. I removed that collection and connected the gallery directly to the data source. That allowed me to Patch directly to the data source. 

    the gallery checkbox, Oncheck property is Collect(colSelected, ThisItem); The

    Remove(colSelected,ThisItem). Sooo, I don't know how to do a check all, but that's for another day.
     
    To patch multiple records in the gallery, I used this option.

     

    UpdateIf(colSelected, true,{Courtroom: {Value: CourtroomBulk.Selected.Value, Id: CourtroomBulk.Selected.Id}}); Patch(BorrowedCalendar,colSelected);Clear(colSelected);Reset(CheckboxAll)

     

     

    UpdateIf(collection, true,{columnname: {Value: Control.Value, Id: Control.Id}}); Patch(data source,collectin;Clear(ccollection)

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 July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 355 Most Valuable Professional

#2
11manish Profile Picture

11manish 209 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 150 Super User 2026 Season 2

Last 30 days Overall leaderboard