Showing results for 
Search instead for 
Did you mean: 
Frequent Visitor

Patching nested collection

I have a collection that looks like this:


Where OT is the Key of the table.


Im trying to patch inside "data" and for that im trying to use this:


Where colFieldsEdited is a collection that contains the columns in "data" that needs an update.


This is my collection "data"



and this is my collection "colFieldsEdited"



My issue here is that this works sometimes, and sometimes it gives me an error "the data source is not valid".

Is there any other way to takle this or avoid the error?

Super User II
Super User II

Hi @TeresaRey 

the Patch() function typically requires three elements,  a datasource or collection, the record being patched and the field in the record being patched inside curly braces with a colon between the fieldname and the new data to overwrite the old data in that field.  Assuming that the Patch is executed from the OnSelect property of an icon or button from inside the gallery, it should look something like this:




 replacing the collectionname with your collection or data source, ThisItem refers to the row in the gallery, and data can be from a control in the gallery row or a lookup to another record if you are patching the datasource of the gallery.  To patch another datasource, replace ThisItem with a Lookup() to the row in the second datasource, typically something like Lookup(datasource2,ID=ThisItem.ID). 

Helpful resources

PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group


Demo Extravaganza Winner Announcement

Please join us on Wednesday, July 21st at 8a PDT. We will be announcing the Winners of the Demo Extravaganza!

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Top Kudoed Authors
Users online (2,011)