Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Answered

How to patch multiple records at once

(2) ShareShare
ReportReport
Posted on by 364
Hi All,
 
I am trying to use the patch function to add files to rows of data with a file column in Dataverse. The issue is, I cannot find a way to get all the files from my collection properly uploaded to their related rows. Below is some code I am using: 
 
ForAll(
        colPurchaseList,  
        Patch(
            'AUNA Purchase Request Line Items',
            Defaults('AUNA Purchase Request Line Items'),
            {
                Item: ThisRecord.Item,
                'Item Description': ThisRecord.Description,
                'PR#': _newPR,
                Quantity: ThisRecord.Quantity,
                Cost: ThisRecord.UnitPrice,
                'Total Cost': ThisRecord.TotalCost,
                'Unit of Measure': ThisRecord.UnitofMeasure,
                Currency: ThisRecord.Currency,
                Taxable: ThisRecord.Taxable,
                Hyperlink: ThisRecord.Hyperlink,
                GUID: ThisRecord.GUID
            }
        )
    );
ForAll(
    colPurchaseList,
    ForAll(
        ThisRecord.Attachment,
        Patch(
            'AUNA Purchase Request Line Items',
            LookUp('AUNA Purchase Request Line Items', GUID = ThisRecord.GUID),
            {
                'PR Document': {
                    FileName: ThisRecord.FileName,
                    Value: ThisRecord.FileContent
                }
            }
        )
    )
);
 
The issue is it only inserts files into the first row created but not all of them. Despite trying to link the GUID value between records, all my files end up in the first row.
 
Does anyone know what I am doing incorrectly here? any feedback is greatly appreciated!
  • Verified answer
    KeithAtherton Profile Picture
    3,690 Most Valuable Professional on at
    How to patch multiple records at once
    Hey. I've encountered a similar issue before and, for me, it helped to alias the records within the nested ForAll() function calls so I'm explicit in which records I'm calling.
     
    I don't know if this code will work but I've tried to illustrate where aliasing can be used - you will likely need trial-and-error to get this code to work:
    ForAll(
        colPurchaseList As PurchaseList,
        ForAll(
            PurchaseList.Attachment As Attachment,
            Patch(
                'AUNA Purchase Request Line Items',
                LookUp('AUNA Purchase Request Line Items', GUID = Attachment.GUID),
                {
                    'PR Document': {
                        FileName: Attachment.FileName,
                        Value: Attachment.FileContent
                    }
                }
            )
        )
    );
     

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

Michael Gernaey – Community Spotlight

We are honored to recognize Michael Gernaey as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 770 Most Valuable Professional

#2
stampcoin Profile Picture

stampcoin 494

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 399