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 / Error when updating it...
Power Apps
Answered

Error when updating items on SP list from a collection

(1) ShareShare
ReportReport
Posted on by 20
I am encountering an issue with a collection on my app. My goal is to check if the data in the collection exists on my SharePoint list or not. If it exists then update the item, if not then just create a new item. I get an error message on the lookup of my code. You will see a error line on the LookUp.
 
 
Error Message:
Error when trying to retrieve data from the network, fetching items failed. Possibly invalid string or filter query. 
 
 
 
If(
  !IsBlank(myCollection),
ForAll(
       myCollection,
Patch(SharePointList, LookUp(SharePointList, ID = ThisRecord.ID),
{
Project: colProjectName,
Quantity:colQuantity
}
)));
 
 
 
 
Categories:
  • Verified answer
    WarrenBelz Profile Picture
    156,921 Most Valuable Professional on at
    Hi
    Firstly, why bother with the collection - try this
    If(
       CountRows(Gallery2.AllItems) > 0,
       Patch(
          CapexExpenseDetails, 
          ForAll(
             Gallery2.AllItems As _Data,
             {
                ID: _Data.ID,
                ProjectDescription: _Data.DescriptionTextbox.Value,
                Quantity: Value(_Data.QuantityTextbox.Value),
                UnitCost: Value(_Data.UnitCostTextbox.Value),
                ExtendedCost: Value(_Data.ExtendedCostTextbox.Value)
             }
          )
       )
    )
     
    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.
     
    Please click 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 giving it a Like.
    MVP (Business Applications)    Visit my blog Practical Power Apps    LinkedIn    Buy me a coffee

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

#2
WarrenBelz Profile Picture

WarrenBelz 207 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 169

Last 30 days Overall leaderboard