cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
TeresaRey
Frequent Visitor

Patching nested collection

I have a collection that looks like this:

TeresaRey_0-1608109157324.png

Where OT is the Key of the table.

 

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

Patch(LookUp(colOTOrders;OT=ThisItem.OT).data;colFieldsEdited);;

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

 

This is my collection "data"

TeresaRey_3-1608109681614.png

 

and this is my collection "colFieldsEdited"

TeresaRey_2-1608109456250.png

 

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?

1 REPLY 1
Drrickryp
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:

 

Patch(collectionname,ThisItem,{field:data})

 

 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

Announcements
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

secondImage

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)