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 / Patching a Sharepoint ...
Power Apps
Answered

Patching a Sharepoint List from a collection

(0) ShareShare
ReportReport
Posted on by 8

I am trying to patch a column (Quantity) in SharePoint list (Stock) using a collection (CollectItems)

In the code below I am trying to locate the record / row  to patch by comparing ItemCode from the collection with the ItemCode of the Stock List. This code seems to be working before. But all of a sudden it stopped working.

 

I can't seem to figure out the problem.

Any help would be much appreciated. 

Here's the code.

 

Patch(Stock, First(Filter(Stock, ItemCode = CollectItems[@ItemCode])) , {Quantity: Balance}))

 

Thanx

Categories:
  • mdevaney Profile Picture
    29,993 Moderator on at

    @Deluxion 

    Hello there.  I have reviewed your code.  My first suggestion is to use LookUp instead of First + Filter because it is faster.

    Patch(Stock, LookUp(Stock, ItemCode = CollectItems[@ItemCode]), {Quantity: Balance}))

     

    There is one problem I see here.  ItemCode (a number) is being compared to the current ItemCode in a Collection so we need to add some more code.

    ItemCode = CollectItems[@ItemCode])

     

    Do you want to loop over the CollectItems collection and update the balance for each Item code.  If yes, please do this 🙂

    ForAll(
     CollectItems,
     Patch(
     Stock,
     LookUp(Stock, ItemCode = CollectItems[@ItemCode]),
     {Quantity: CollectItems[@Balance]}
     )
    )

     

    ---
    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."

  • Verified answer
    Deluxion Profile Picture
    8 on at

    @mdevaney  Thanks for your quick response.

    Unfortunately that didn't work. Kept getting the same error.

    As suggested I have used LookUp instead of Filter in my code.👍

     

    Here's is the final code that worked for me.

    ForAll(RenameColumns(CollectItems, "ItemCode", "ItemCode1"),Patch(Stock,LookUp(Stock,ItemCode=ItemCode1),{Quantity:Balance}))

     

    Apparently the same column name in collection and SharePoint list was the main culprit.

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

#2
WarrenBelz Profile Picture

WarrenBelz 188 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 120

Last 30 days Overall leaderboard