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 / How insert multiple re...
Power Apps
Answered

How insert multiple records at time into CDS without using ForAll

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi,
We have 50 records that needs to be inserted into CDS in a single batch operation from canvas app. If we use ForAll and Patch it hits the CDS 50 times and is taking so much time to insert. It is Impacting the app performance. Can we insert all the records at once without using loop. 

Thanks in Advance.

Categories:
I have the same question (0)
  • Verified answer
    RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @devipriyanka 

    In general, you are probably doing a ForAll(data), Patch(dataSource, ...)  formula.  Patch takes a table as well.  ForAll is a PowerApps function that is used to return a Table of iterated items.

    So, if you use the ForAll properly as a table generating function, then you can use that as the records argument of the Patch statement.

    Ex.  Patch(yourDataSource, ForAll(yourrecords, {ID: ID, x: y, z:a}) )

    In this, the ForAll creates a Table of records with the changes you want to make.  That Table is then used in the Patch to submit all of the records at once.

     

    NOW...that said, internally the Patch will still do this record by record.  But, I still have found that the performance of this is much better than trying to use ForAll as a For/Loop.   Patch gets a full table to work on at a time rather than record by record.  It seems to like it a little more in the performance area.

     

    I hope this is helpful for you.

  • Verified answer
    mdevaney Profile Picture
    29,991 Moderator on at

    @devipriyanka 
    Follow this tutorial.  It will show you how to do insert all 50 records at once.

    Article: Patch Multiple Records In Power Apps 10x Faster
    https://matthewdevaney.com/patch-multiple-records-in-power-apps-10x-faster/

     

    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

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

    Yep...same concept.  Just without collections.

  • devipriyanka Profile Picture
    Microsoft Employee on at

    @RandyHayes and @mdevaney  Thank you. This is really helpful. 

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 547

#2
WarrenBelz Profile Picture

WarrenBelz 444 Most Valuable Professional

#3
Valantis Profile Picture

Valantis 322

Last 30 days Overall leaderboard