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 data from a f...
Power Apps
Answered

Patching data from a form and collection into sharepoint list, multiple records with same ID necessary

(0) ShareShare
ReportReport
Posted on by 30

Hello,

I am working on a supply ordering app where products and quantities are selected and added to a collection (colOrderItems) and an order contact plus any comments are collected via an edit form. I need to patch all of the order data- products ordered, their quantities, order contact, and any comments. Ideally, the records would be created with the same ID but different Product Ordered and Quantity values for every item selected. I currently have the following code in the OnSelect property of my submit button:

 

SubmitForm(Form2_1);

ForAll(
colOrderItems,
Patch( Order,
First(Sort(Order, Modified, Descending)),
{
'Order Contact': DataCardValue9_1.Selected,
ID: Value(ThisRecord.ID),
'Order Contact': ThisRecord.'Order Contact',
'Product Ordered': ThisRecord.'Product Ordered',
Quantity: ThisRecord.Quantity,
'Special Request': ThisRecord.'Special Request',
SupplyID: ThisRecord.SupplyID
}
)
);

 

When the form is submitted, a record is created containing the order contact, special request/comments, and ID. My assumption was that I would need to edit that record and patch the data for every item in the collection. However, I have tried reconfiguring many different ways and "the patch function has some invalid arguments" error persists.

Categories:
  • WarrenBelz Profile Picture
    156,963 Most Valuable Professional on at

    Hi @ellaling ,

    The ID field in SharePoint is a unique sequential automatically generated number and cannot be patched to. You will need to create a separate numeric field if you want an identifier.

     

    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

  • ellaling Profile Picture
    30 on at

    Hi,

    When I remove the patching to the ID field, my errors persist.

  • Verified answer
    WarrenBelz Profile Picture
    156,963 Most Valuable Professional on at

    @ellaling ,

    Actually your issue is here

    First(Sort(Order, Modified, Descending)),

    You are trying to patch the entire collection to the same record. If you want to create new records

    Patch( 
     Order,
     ForAll(
     colOrderItems As _Order,
     {
     'Order Contact': DataCardValue9_1.Selected,
     'Order Contact': _Order.'Order Contact',
     'Product Ordered': _Order.'Product Ordered',
     Quantity: _Order.Quantity,
     'Special Request': _Order.'Special Request',
     SupplyID: _Order.SupplyID
     }
     )
    );

    To update existing records based on the ID

    Patch( 
     Order,
     ForAll(
     colOrderItems As _Order,
     {
     ID: _Order.ID,
     'Order Contact': DataCardValue9_1.Selected,
     'Order Contact': _Order.'Order Contact',
     'Product Ordered': _Order.'Product Ordered',
     Quantity: _Order.Quantity,
     'Special Request': _Order.'Special Request',
     SupplyID: _Order.SupplyID
     }
     )
    );

    I am assuming that DataCardValue9_1 is separate from the collection.

     

    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

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

#2
WarrenBelz Profile Picture

WarrenBelz 189 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 126

Last 30 days Overall leaderboard