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 / Copying all records in...
Power Apps
Answered

Copying all records in CollectionA to corresponding record in CollectionB

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

I'm copying all the contents of the GroupItems collection onto the same ID in the PSOCache collection. Both collections have the same set of columns. Patch does not work because of the empty fields bug. I'm looking for a succinct way to make this work.

ForAll(
 RenameColumns(GroupItems
 , "ID"
 , "ContentID"
 ),
 UpdateIf(
 PSOCache
 , ID=ContentID
 , {
 Status: Status
 , StatusText: StatusText
 , 'Status Detail': 'Status Detail'
 , Inspected: Inspected
 , MSF: MSF
 , SN: SN
 , Ticket: Ticket
 , 'Vendor Part Number': 'Vendor Part Number'
 , Description: Description
 , Bin: Bin
 , Edited: Edited
 }
 )

 

 

Categories:
  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @sopatte 

    So, you mentioned Patch as an issue, but your formula is using UpdateIf.  Are you having a particular issue with that formula?

  • SoPatt Profile Picture
    Microsoft Employee on at

    I'm working around the Patch issue.

     

    Yes. I believe there's a scoping issue in my formula. I want to update each record in PSOCache with the contents of the corresponding record in GroupItems.

     

    Also tried:

    UpdateIf(
     PSOCache,
     true,
     Lookup(GroupItems,ID=PSOCache[@ID])
    )

     

     

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @sopatte 

    At a glance...your initial formula you posted should have worked.  What issues are you finding with it?

  • SoPatt Profile Picture
    Microsoft Employee on at

    I believe within the record being passed as the third argument to UpdateIf, the values are scoped to PSOCache.

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @sopatte 

    That may or may not be the case.  I find that PowerApps is usually smart enough to work this out without an issue.  Sometimes..at least 😉 

    So, my question would be - have you tried that formula and have you noticed an issue with it that would lead you to a scoping issue?

    If so, then perhaps change your individual assignments to statements similar to this:

     { Status: GroupItems[@Status]
     , StatusText: GroupItems[@StatusText]
     , etc....

     

  • Verified answer
    SoPatt Profile Picture
    Microsoft Employee on at

    Your suggestion won't *quite* work because there is no record scope for GroupItems. The record scope within ForAll is 

     RenameColumns(GroupItems
     , "ID"
     , "ContentID"
     )

    The documentation says, "If the table being operated upon is an expression, such as Filter( Table, ... ), then the disambiguation operator cannot be used. Only the innermost record scope can access fields from this table expression, by not using the disambiguation operator." although I'm not quite sure what that last sentence means. 

     

    But you did give me an idea. This seems to work:  

    ForAll(
     GroupItems,
     UpdateIf(
     PSOCache,
     ID=GroupItems[@ID],
     {
     Status: GroupItems[@Status]
     , StatusText: GroupItems[@StatusText]
     , 'Status Detail': GroupItems[@'Status Detail']
     , Inspected: GroupItems[@Inspected]
     , MSF: GroupItems[@MSF]
     , SN: GroupItems[@SN]
     , Ticket: GroupItems[@Ticket]
     , 'Vendor Part Number': GroupItems[@'Vendor Part Number']
     , Description: GroupItems[@Description]
     , Bin: GroupItems[@Bin]
     , Edited: GroupItems[@Edited]
     }
     )
    );
    Back()

    Thanks!

  • SoPatt Profile Picture
    Microsoft Employee on at

    I've suggested this feature before but how great would it be if in any record scope ThisItem was defined to refer to the entire record?

    ForAll(
     GroupItems,
     UpdateIf(
     PSOCache,
     ID=GroupItems[@ID],
     GroupItems[@ThisItem]
     )
    )

     

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @sopatte 

    Agreed.

    You can get close though with this type of construct:

     

    ForAll(GroupBy(RenameColumns(GroupItems, "ID", "colAID"), "colAID", "ThisItemA"),
    UpdateIf(PSOCache, ID=colAID, 
    {
     Status: First(ThisItemA).Status
     , StatusText: First(ThisItemA).StatusText
     
    etc...

     

     

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 337 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 250

#3
Mohsin Ali Profile Picture

Mohsin Ali 225

Last 30 days Overall leaderboard