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 / Patching a collection ...
Power Apps
Answered

Patching a collection issue

(0) ShareShare
ReportReport
Posted on by 85

Hi all,

I have a Sharepoint list that i'm building a collection from.  I'm then editing entries in the collection, and also adding new ones using Collect.  

I'm collecting new entries to the collection, so those new entries won't have an ID yet.  When I try to write the collection back to the datasource using Collect(datasource,collection), only the NEW entries that were added to the collection show up in the datasource.  The existing rows I edit in the collection are being modified as expected within the collection, but they aren't patching back to the datasource.  I'm trying to avoid using a Forall if possible since the collection may often have lots of rows that aren't modified at all.


Any suggestions?

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

    Hi @russrimm1 ,

     

    Collect would only add new entries into the data source. 

     

    To accomplish your need, you could add a field say "Update" in the collection. When modifying a record in the collection, set the value of this field to be "true", as well as using Collect() to add new records into the collection.

     

    When updating the data source, now you could use ForAll along with Patch because you will be able to filter out all the records those Update field = true :

    ForAll(
     Filter(collection, Update = true), 
     If(
     IsBlank(ThisRecord.ID),
     Patch(
     DataSource, 
     Defaults(DataSource), 
     {Field1:...,Field2:...,Field3:...,...}
     ),
     Patch(
     DataSource,
     LookUp(DataSource,ID = ThisRecord.ID),
     {Field1:...,Field2:...,Field3:...,...}
     )
     )
    )

     

    Hope this helps.

     

    Best regards,

    Community Support Team _ Jeffer Ni
    If this post helps, then please consider Accept it as the solution to help the other members find it.

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

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 534

#2
WarrenBelz Profile Picture

WarrenBelz 416 Most Valuable Professional

#3
Valantis Profile Picture

Valantis 306

Last 30 days Overall leaderboard