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
Suggested answer

Power Apps not saving all gallery/collection items to SharePoint

(0) ShareShare
ReportReport
Posted on by 26

Dear All,

I have a Power Apps app that collects multiple order items in a collection called Cart and then saves them into a SharePoint list using ForAll(Patch(...)).

 

It used to work but recently I discovered that not all items are being saved into the SharePoint list. The SharePoint list ends up incomplete even after waiting. At first I thought that my power automate flows was triggered before all items are saved in the sharepoint, so that's why I did not get a full items list in my pdf. but upon checking is that shouldn't my sharepoint list should have the complete list even if my trigger fired to early causing incomplete pdf doc being created?

 

But it will come up eventually the full order list after multiple trials.

 

Here is my power apps submit order formula:

 
Set(varRecordID,
Patch('Shopping Cart / Order Remarks', Defaults('Shopping Cart / Order Remarks'),
{
Title: If(Remarks.Selected.Value="Others", OthersComments.Text, Remarks.Selected.Value),
User: FullName.Text
}
).ID
);

ForAll(
Cart,
Patch('Shopping Cart / Checkout', Defaults('Shopping Cart / Checkout'),
{
'Name (Title)': Name,
Image: Image,
Unit: Unit,
Date: DateTimeValue(Date.Text),
Quantity: Quantity,
OrderID: varRecordID,
Remarks: If(Remarks.Selected.Value="Others", OthersComments.Text, Remarks.Selected.Value)
}
)
);

Reset(Remarks);
Reset(OthersComments);
Clear(Cart);
Navigate('Successful Place Order', ScreenTransition.Cover);
 

 

 

The problem:

  • Power Apps saves only some rows from Cart.

  • Others never appear in the SharePoint list.

  • The missing items do not appear even after a long time.

  • So the issue is not timing, but Patch failing silently.


  •  
 

My question:

What is the correct way to ensure all items inside a collection are patched reliably to SharePoint?

Is there a recommended pattern for troubleshooting silent Patch failures inside a ForAll?

 

Thanks in advance!



     
Categories:
I have the same question (0)
  • Suggested answer
    MS.Ragavendar Profile Picture
    4,553 Super User 2025 Season 2 on at
    Power Apps not saving all gallery/collection items to SharePoint
     
    We creating one collection to capture any errors while patching.
    ClearCollect(
        PatchErrors,
        ForAll(
            Cart,
            Patch(
                'Shopping Cart / Checkout',
                Defaults('Shopping Cart / Checkout'),
                {
                    'Name (Title)': Name,
                    Image: Image,
                    Unit: Unit,
                    Date: DateTimeValue(Date.Text),
                    Quantity: Quantity,
                    OrderID: varRecordID,
                    Remarks: If(Remarks.Selected.Value="Others", OthersComments.Text, Remarks.Selected.Value)
                }
            )
        )
    );
     
    If(CountRows(PatchErrors) <> CountRows(Cart),
        Notify("Some items failed to save!", NotificationType.Error),
    Notify("Records Saved", NotificationType.Success),
    )
    
     
    🏷️ Please tag me @MS.Ragavendar if you still have any queries related to the solution or issue persists.
    Please click Accept as solution if my post helped you solve your issue and help others who will face the similar issue in future.
    ❤️ Please consider giving it a Like, If the approach was useful in other ways.
  • Suggested answer
    CU19111247-0 Profile Picture
    on at
    Power Apps not saving all gallery/collection items to SharePoint
    Hello @laclws
     
    I’ve seen this issue before, what you’re experiencing is a common scenario in Power Apps when using ForAll(Patch(...)) with SharePoint. The key problem is that Patch can fail, especially if.
     
    #1. Some fields in SharePoint are required and the values are missing.
    #2. There are data type mismatches
     
    To fix this, you can use error-aware Patch logic and then verify that every item was saved successfully.
     
    // 1. Create parent order and get its ID
    Set(
        varRecordID,
        Patch(
            'Shopping Cart / Order Remarks',
            Defaults('Shopping Cart / Order Remarks'),
            {
                Title: If(Remarks.Selected.Value="Others", OthersComments.Text, Remarks.Selected.Value),
                User: FullName.Text
            }
        ).ID
    );
    
    // 2. Clear previous failed items log
    Clear(c_FailedItems);
    
    // 3. Patch each item in Cart with error handling (modern As syntax)
    ForAll(
        c_Cart As _obj,
        If(
            !IsError(
                Patch(
                    'Shopping Cart / Checkout',
                    Defaults('Shopping Cart / Checkout'),
                    {
                        'Name (Title)': _obj.Name,
                        Image: _obj.Image,
                        Unit: _obj.Unit,
                        Date: DateTimeValue(_obj.Date),
                        Quantity: _obj.Quantity,
                        OrderID: varRecordID,
                        Remarks: If(_obj.Remarks.Selected.Value="Others", _obj.OthersComments.Text, _obj.Remarks.Selected.Value)
                    }
                )
            ),
            true, // success, do nothing
            Collect(c_FailedItems, _obj) // log failed items
        )
    );
    
    // 4. Notify user if any failures
    If(
        CountRows(c_FailedItems) > 0,
        Notify("Some items failed to save. Please retry.", NotificationType.Error),
        Notify("All items saved successfully!", NotificationType.Success)
    );
    
    // 5. Reset form and collection
    Reset(Remarks);
    Reset(OthersComments);
    Clear(c_Cart);
    Navigate('Successful Place Order', ScreenTransition.Cover);
    
     
     
     
    📩 Need more help? Mention @CU19111247-0 anytime!
    ✔️ Don’t forget to Accept as Solution if this guidance worked for you.
    💛 Your Like motivates me to keep helping!
     
     
  • WarrenBelz Profile Picture
    151,957 Most Valuable Professional on at
    Power Apps not saving all gallery/collection items to SharePoint
    Hi @laclws,
    Assumign Cart is a Collection, you can do this - note the _Items prefix only applies if the field is in the collection - if not. leave it off. Also 
    ForAll is not designed to be a loop, although it can act that way if it contains an action inside it. ForAll creates a Table, which can be Patched in one action to the data source and will run much faster than individual Patches for each record. If it contains the ID of each record, it will update the specific records, if not it will create new records as in your case)
    Patch(
       'Shopping Cart / Checkout',
       ForAll(
          Cart As _Items,
          {
             'Name (Title)': _Items.Name,
             Image: _Items.Image,
             Unit: _Items.Unit,
             Date: DateTimeValue(Date.Text),
             Quantity: _Items.Quantity,
             OrderID: varRecordID,
             Remarks: 
             If(
                Remarks.Selected.Value ="Others", 
                OthersComments.Text, 
                Remarks.Selected.Value
             )
          }
       )
    );
    If Cart is your Gallery, you need Cart.AllItems
     
    Please Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider answering Yes to Was this reply helpful? or give it a Like
    Visit my blog
    Practical Power Apps    LinkedIn  
  • Suggested answer
    jyotiatharv Profile Picture
    65 on at
    Power Apps not saving all gallery/collection items to SharePoint
    Try below to get the error:-
    Clear(colPatchErrors);
    ForAll(
        Cart,
        With(
            {
                result: Patch(
                    'Shopping Cart / Checkout',
                    Defaults('Shopping Cart / Checkout'),
                    {
                        'Name (Title)': Name,
                        Image: Image,
                        Unit: Unit,
                        Date: DateTimeValue(Date.Text),
                        Quantity: Quantity,
                        OrderID: varRecordID,
                        Remarks: If(Remarks.Selected.Value="Others", OthersComments.Text, Remarks.Selected.Value)
                    }
                )
            },
            If(
                IsError(result),
                Collect(colPatchErrors, { Item: ThisRecord, Name:Name, Error: Errors('Shopping Cart / Checkout') })
            )
        )
    );
     

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

Coming soon: forum hierarchy changes

In our never-ending quest to improve we are simplifying the forum hierarchy…

Chiara Carbone – Community Spotlight

We are honored to recognize Chiara Carbone as our Community Spotlight for November…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 658 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 380 Super User 2025 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 242 Super User 2025 Season 2

Last 30 days Overall leaderboard