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 / Save gallery data havi...
Power Apps
Answered

Save gallery data having 200 rows taking 2min

(0) ShareShare
ReportReport
Posted on by 158

Hi ALL,

 

I need your help -

I have one gallery which have almost 200 rows , so i am trying to create new row for each gallery row in my SQL db. It is taking approximate 3 to 4 min to save gallery data. Is there is any way to optimize the code for saving gallery data having large now of rows?

code using:

Patch(employeedata,
ForAll(Gallery4_3.AllItems As passThrough5,
{employee_id:Value(vaempID),emptempid:passThrough5.emptemp_id,workLocation:If(IsBlank(passThrough5.ComboBox7_3.SelectedItems),passThrough5.TextInput4_3.Text,passThrough5.ComboBox7_3.Selected.worklocationID)}))

Categories:
  • zmansuri Profile Picture
    6,048 Super User 2024 Season 1 on at

    This will be heavy operation to write in forALL,

    My suggestion is create a stored procedure in your db for this. And then call the stores procedure from the power automate flow. It will be faster.

  • Verified answer
    ridhan Profile Picture
    158 on at

    Hi @zmansuri - I have not worked much on stored procedure. Can you please guide me how to do that? Also will it take all the changes done in powerapss gallery and create new row for each row?

  • cdwhite Profile Picture
    1,069 Most Valuable Professional on at

    Hi @ridhan ,

    If your schema's match, you could try a slightly different approach.

    1. Add all the gallery items to an internal collection first, this should be quicker, then
    2. Patch the collection back to the data source. It will automatically add any new records or edit existing ones.

    You'd therefore have code looking something like this:

     

    ClearCollect(colYourCollection,
     ForAll(Gallery4_3.AllItems As passThrough5,
     {employee_id:Value(vaempID),
     emptempid:passThrough5.emptemp_id,
     workLocation:
     If(IsBlank(passThrough5.ComboBox7_3.SelectedItems),
     passThrough5.TextInput4_3.Text,
     passThrough5.ComboBox7_3.Selected.worklocationID)
     })
    );
    
    Patch(SQLTable, colYourCollection)

     

    Personal experience, that approach can be quicker more often than not. Perhaps see if it works for you too.

    The alternative is to call a Flow from your app and pass the data through, and let Flow add the records instead.

    ------------------------------------------------------------------------------------------------------------------------------
    If I've answered your question, please mark your post as Solved. You can accept more than one post as a solution.

    If my response was a good one, please give it a Thumbs Up!

    Visit my blog: https://platformsofpower.net

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

#2
M Bilal Khan Profile Picture

M Bilal Khan 330

#3
Mohsin Ali Profile Picture

Mohsin Ali 232

Last 30 days Overall leaderboard