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 / Patch collection to co...
Power Apps
Answered

Patch collection to collection

(0) ShareShare
ReportReport
Posted on by 5,836 Moderator

In my app I have a need to patch a collection with data from another collection.  

 

It sort of works, but I know I am missing something and so far have not been successful in figuring it out.

 

Scenario:

Choice is made in app and collect action populates the collection.   If a second choice is made the new data is patched to the collection that was just populated.  This isn't the typical repeating table scenario, however.

 

Multiple items are being populated into the collection each time.

 

  • Data Source:  SharePoint list
  • Collection: Market2
  • Collection: Market4
  • Dropdown Control with Regions

 

  • User selects region - Markets2 is populated with all the countries belonging to that region
  • User selects 2nd region - Markets 4 is populated with all the countries in that region

MarketsCollections.png

  • Markets4 is patched to Markets2, adding all the newly selected countries.

marketspatchformula.png

 

As you can see in the images below the patch is only patching one record in Markets4 to Markets2 and not all the fields, only the Country and Country Code.   Patch(Markets2, {Column3: Region}.... or Patch(Markets2, {Column3: Title}.... return the same results.   No errors either.

 

Markets4 Collection

markets4Collection.png

 

Markets2 collection after patch

markets2Afterpatch.png

 

 

 

Categories:
  • amitchandak Profile Picture
    95 on at
  • JR-BejeweledOne Profile Picture
    5,836 Moderator on at

    Thank you but no, I have the basics working correctly.   I believe my issue is something to do with the ForAll.    It correctly patches the first record of the Markets4 collection to the Markets2 collection.  It just doesn't patch the remaining records.

  • Verified answer
    v-bofeng-msft Profile Picture
    Microsoft Employee on at

    Hi @JR-BejeweledOne :

    Do you want to add the records in Markets4 to Markets2?

    Firstly,let me explain why you encounted this problem.

    The key is that when you need to Modify or create a record in a data source, the second parameter of the Patch function is BaseRecord.

    BaseRecord:The record to modify or create. If the record came from a data source, the record is found and modified. If the result of Defaults is used, a record is created.

    Secondly,Please try this code:

     

    ForAll(Marktes4,Patch(Markets2,Defaults(Markets2),{Column3:Region,Column2:Country,Title:CountryCode}))

     

     I think this link will help you a lot:

    https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-patch#syntax

    Best Regards,

    Bof

  • JR-BejeweledOne Profile Picture
    5,836 Moderator on at

    Thank you, That worked.   I was missing the 'Defaults (Markets2).

     

    Is the 'Defaults(Name)' a specific requirement of the ForAll patch?   I don't have to use it when patching with thisitem.xxxx

     

     

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

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 342 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 271

#3
Mohsin Ali Profile Picture

Mohsin Ali 223

Last 30 days Overall leaderboard