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 collection to...
Power Apps
Answered

Patching collection to Sharepoint List for inventory management

(0) ShareShare
ReportReport
Posted on by 224

I'm creating an inventory management app and I'm trying to patch certain items in a SharePoint list based on a collection.

 

Below is the code I'm trying to use, but I get an error trying to reference the Amount in the SharePoint list.

 

How can I reference the Amount from the SharePoint list, so the Patch code works correctly?

 

 

ForAll(colCartFinal As aRecord,Patch('Uniform Inventory',LookUp('Uniform Inventory',Title=aRecord.Product && Sizes=aRecord.Size),{Amount:Value(Amount-aRecord.TotalNeeded)}))

 

 

as733y_0-1705958632815.png

 

Categories:
I have the same question (0)
  • v-bofeng-msft Profile Picture
    Microsoft Employee on at

    Hi  @as733y ï¼Œ 

     

    Could you please show me the error message?

     

    Please check the value of 

    Amount-aRecord.TotalNeeded

     

    Best Regards,

    Bof

  • Verified answer
    WarrenBelz Profile Picture
    154,930 Most Valuable Professional on at

    Hi @as733y ,

    Assuming TotalNeeded is numeric, try this

    Patch(
     'Uniform Inventory',
     ForAll(
     colCartFinal As aRecord,
     With(
     {
     _SPItem:
     LookUp(
     'Uniform Inventory',
     Title = aRecord.Product && 
     Sizes = aRecord.Size
     )
     },
     {
     ID: _SPItem.ID,
     Amount: _SPItem.Amount - aRecord.TotalNeeded
     }
     )
     )
    )

     

    Please click Accept as solution 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 Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • as733y Profile Picture
    224 on at

    Thank you @WarrenBelz! It appears to be working.

     

    Can you please explain the ID part of the code? I think I understand everything else in the With function

     ID: _SPItem.ID,

     

  • WarrenBelz Profile Picture
    154,930 Most Valuable Professional on at

    Hi @as733y ,

    The With() function simply retrieves the full target record and then two field values are used in the Patch - the ID as this ensures the correct record is Patched in each itineration of the ForAll (which in the structure I have posted actually makes a Table and "bulk patches" it all at once) and the Amount - "pre-fetching" it is far better than trying to patch a field using its existing value directly in the calculation.

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 541

#2
WarrenBelz Profile Picture

WarrenBelz 434 Most Valuable Professional

#3
Valantis Profile Picture

Valantis 289

Last 30 days Overall leaderboard