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 only bringing th...
Power Apps
Unanswered

Patch only bringing through last item

(0) ShareShare
ReportReport
Posted on by 196

Hello,

 

Trying to patch to a sharepoint list buts only bringing through the last item, I guess I need to add a forall but not sure where?

 

Set(varRecordID,Patch('Shopping Cart Orders',Defaults('Shopping Cart Orders'),{Title:Product.Text}).ID)

 

Any ideas?

 

Thanks

Ross

Categories:
  • cha_cha Profile Picture
    4,932 Moderator on at

    Hello @rosscortb 

     

    Kindly please explain what you want to achieve.

     

    I see that your code is making a new Item on the list.

  • victorcp Profile Picture
    2,350 Moderator on at

    Hi,

    I didn't understand what you want here, but what your code does is creating a new record in the list 'Shopping Cart Orders' and save its ID in the variable varRecordID that's why it always get the last Item.

     

    If you want to update an item you should do this:

    Set(varRecordID,Patch('Shopping Cart Orders',LookUp('Shopping Cart Orders', ID = ItemIdToUpdate),{Title:Product.Text}).ID)

  • rosscortb Profile Picture
    196 on at

    @victorcp  Hello

    Thanks for responding.

    Sharepoint list is this:

     

    Shopping cart orders.png

    Checkout is:

    rosscortb_0-1670333424379.png

     

     

    So, it had the code on place order but only patched Sherry cask item.

     

    Tried your code @victorcp but struggled to work, ID wasn't picking up.

     

    It does bring in both with:

    Patch('Shopping Cart Orders',ForAll('Basket order'.AllItems,{Title:ThisRecord.Product}))

     

    But don't know how to get varRecordID added.

     

    Hope that makes sense.

     

    Thanks
    Ross

     

  • victorcp Profile Picture
    2,350 Moderator on at

    Ok, now I undestood your problem.
    you can use ForAll to send all the info to ShP and it will be something like this:

    Set(
     varRecordID,
     ForAll(
     'Basket order'.AllItems, 
     Patch(
     'Shopping Cart Orders',
     Defaults('Shopping Cart Orders'),
     {Title:ThisRecord.Product.Text}
     ).ID
     )
    )

     

    I hope it helps 🙂

  • rosscortb Profile Picture
    196 on at

    @victorcp Thanks. Apologies, I have a little try yesterday and here is where I go to.

    From articles I have read, I can have a sharepoint list - Shopping Cart Orders - I have product, ID & OrderID and then I have a second sharepoint list - Shopping Cart Order Items - Where I have more columns and I should be bringing in the OrderID column.

    rosscortb_0-1670405917189.png

     

    rosscortb_1-1670405963914.png

    Not sure if I need this second list but that's what I have read online.

     

    Code is:

    Refresh('Shopping Cart Orders');Set(varOrderID,Last('Shopping Cart Orders').ID+1);ForAll(Basket,Patch('Shopping Cart Orders',Defaults('Shopping Cart Orders'),{Title:Product},{OrderID:varOrderID}));
    
    
    Patch('Shopping Cart Order Items',
    
     ForAll(Basket As _item,
     {
     ID:_item.ProductID,
     Title:_item.Product,
     SalesQuantity:_item.SalesQuantity,
     PointsQuantity:_item.PointsQuantity,
     Price:_item.Price
     
     
     
     }))

     

    Not sure how I get the OrderID through to the Shopping Cart Order Items list?

    Any ideas?

    Thanks
    Ross

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

#2
Mohsin Ali Profile Picture

Mohsin Ali 338

#3
WarrenBelz Profile Picture

WarrenBelz 256 Most Valuable Professional

Last 30 days Overall leaderboard