Announcements
Hi My Patch function only creates one row....
First I create a collection with mulitple records in it.
Then I patch the collection to the data source
but the data source only receives the last record created.. What am I doing wrong
@IzabEwa ,
Supposing that the structure is similar between the datasource PowerSalesLines and the collection LineItems, use:
Patch(PowerSalesLines, LineItems)
that wont work as i need to add an external field that isnt included in the collection (a guid)
Add that the column to the collection using:
AddColumns(Collection,"NameOftheColumnAsInDataSource", GuidValueAsNeeded)
Anyway I don't know the background, so you can use ForAll() function ( this approach is time consumer as you make a patch request for each line from your collection):
ForAll(LineItems, Patch(PowerSalesLines,Defaults(PowerSalesLines), {Item_Description:Item_Description,..... } ) )
this updates the record with the last item of the collection x amount of all the items, ie. if there are 8 records and the last one is tomato there will be 8 tomato records
Not to get me wrong, With Item_Description, I'm not reffering to the control value, it is the LineItems column Item_Description:
ForAll(LineItems, Patch(PowerSalesLines,Defaults(PowerSalesLines),{Item_Description:Item_Description,..... }))
That didnt help , the same thing still happens
you need to use ForAll ( loop to go over all items in the collection and patch one by one) to do the update or create based on what you want with specifying the current record that you want to patch like below,
ForAll(LineItems, Patch(PowerSalesLine,Defaults(PowerSalesLines), { Item_Description: ThisRecord.ItemDescription, ... }) )
so you need to add (ThisRecord) to make sure that the current item in the loop is selected
I tried that
but i get this error
The method and code are correct, the problem seems to be from the value itself inside the collection, it seems the value is empty while it's a mandatory field or the value is not valid.
The method and code are correct, the problem seems to be from the value itself inside the collection, it seems the value is empty while it's a mandatory field or the value is not valid
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.
Congratulations to our community stars!
Expanding mentorship, skilling, and AI innovation
These are the community rock stars!
Stay up to date on forum activity by subscribing.
11manish 342 Super User 2026 Season 2
M Bilal Khan 283
Mohsin Ali 221