web
You’re offline. This is a read only version of the page.
close
Skip to main content
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!
I have the same question (0)
  • 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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Tom Macfarlan – Community Spotlight

We are honored to recognize Tom Macfarlan as our Community Spotlight for October…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 998 Most Valuable Professional

#2
developerAJ Profile Picture

developerAJ 426

#3
Michael E. Gernaey Profile Picture

Michael E. Gernaey 257 Super User 2025 Season 2

Last 30 days Overall leaderboard