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 / Patch from Collection ...
Power Apps
Answered

Patch from Collection to Sharepoint List

(0) ShareShare
ReportReport
Posted on by

Hey together,

 

I'm struggeling with patching values from a collection to sharepoint list. In my case I have to add or subtract the value "quantity" from collection to the existing "quantity" in my sharepoint list. 
"Serial number" is unique for every element in my sharepoint list so the patch should map it correctly via the serial number.

I tried it with the following lookup but thats not working...

ForAll(
 colReturnCart;
 Patch(
 Elektroteileliste; LookUp(Elektroteileliste; 
 Value(Elektroteileliste[@Serialnumber])=Value(colReturnCart[@Serialnumber]));
 {'Inventory in stock': Value(LookUp(Elektroteileliste; Value(Serialnumber) = 
 Value(ThisRecord.Serialnumber)).'Inventory in stock') + colReturnCart[@Quantity];
 'Inventory in circulance': Value(LookUp(Elektroteileliste; Value(Serialnumber) = 
 Value(ThisRecord.Serialnumber)).'Inventory in circulance') - colReturnCart[@Quantity]}
 )
)

 "colReturnCart" is the collection and "Elektroteileliste" is my sharepoint list.

"Inventory in stock" and "Inventory in circulance" are the Columns in my list to patch.

 

Thanks for helping,

 

Lukas

Categories:
I have the same question (0)
  • Verified answer
    WarrenBelz Profile Picture
    154,426 Most Valuable Professional on at

    Hi @luwu_7100 ,

    Firstly can you please try this

    Patch(
     Elektroteileliste;
     ForAll(
     colReturnCart As aCol;
     With(
     {
     wRecord:
     LookUp(
     Elektroteileliste; 
     Serialnumber = aCol.Serialnumber
     )
     };
     {
     ID: wRecord.ID;
     'Inventory in stock': wRecord.'Inventory in stock' + aCol.Quantity;
     'Inventory in circulance': wRecord.'Inventory in circulance' - aCol.Quantity
     }
     )
     )
    )

    I will also offer some fundamental advice here that may assist with this and future ForAll() exercises. It is not designed to be a Loop, although it can work this way with considerable performance penalty as it does an individual Patch for each record. ForAll() creates a Table, which can be patched in one action provided its content is correct. For new records, this is simply a Table with field names and field types matching the list. For existing records, including the SharePoint record ID in the table causes it to update that record for each of the Table records.

     

    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

  • luwu_7100 Profile Picture
    on at

    Hello Warren,

     

    thank you for helping.

    I tried to implement your code, but when I get to the point, where I put in the last 3 rows,

    ID: wRecord.ID;
     'Inventory in stock': wRecord.'Inventory in stock' + aCol.Quantity;
     'Inventory in circulance': wRecord.'Inventory in circulance' - aCol.Quantity

    then it doen't find the following arguments, so I can't put them into the formula...

     

    Thanks,

    Lukas

     

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

    Hi @luwu_7100 ,

    Exactly where I have them - I just tested the code here on a Test list with the same field types and it works as expected

    WarrenBelz_0-1680166734363.png

     

    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

     

  • luwu_7100 Profile Picture
    on at

    Hi @WarrenBelz ,

    I tried the code exactly like you discribed. Here can you see exactly what I put in: (collection name and serial number is in German in my case)

    Patch(
     Elektroteileliste;
     ForAll(
     colRückgabekorb As aCol;
     With(
     {
     wRecord:
     LookUp(
     Elektroteileliste;
     Value(Materialnummer) = Value(aCol.Materialnummer)
     )
     };
     {
     

    But at this point here I have no option to select ID, so I can't go on typing in your code..

    Can you see any mistake?

    Thanks,

    Lukas

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

    Hi @luwu_7100 ,

    Just paste/type it in - you do not have to rely on intellisense. The main issue it getting no errors when you are finished.

  • luwu_7100 Profile Picture
    on at

    Hello Warren,
    your solution worked well since I integrated it in my app.

    But since this week, the patch doesn't work anymore and I get the error "Network error while using the patch function: The field "title" is nescessary".

    Do you have any idea what could be the reason for this issue?
    I am very confused an have no idea whats the problem...

     

    Thank you

    Lukas

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!

Leaderboard > Power Apps

#1
wolenberg_ Profile Picture

wolenberg_ 119 Super User 2026 Season 1

#2
WarrenBelz Profile Picture

WarrenBelz 107 Most Valuable Professional

#3
Haque Profile Picture

Haque 103

Last 30 days Overall leaderboard