
Hi all,
I have a Sharepoint list that i'm building a collection from. I'm then editing entries in the collection, and also adding new ones using Collect.
I'm collecting new entries to the collection, so those new entries won't have an ID yet. When I try to write the collection back to the datasource using Collect(datasource,collection), only the NEW entries that were added to the collection show up in the datasource. The existing rows I edit in the collection are being modified as expected within the collection, but they aren't patching back to the datasource. I'm trying to avoid using a Forall if possible since the collection may often have lots of rows that aren't modified at all.
Any suggestions?
Hi @russrimm1 ,
Collect would only add new entries into the data source.
To accomplish your need, you could add a field say "Update" in the collection. When modifying a record in the collection, set the value of this field to be "true", as well as using Collect() to add new records into the collection.
When updating the data source, now you could use ForAll along with Patch because you will be able to filter out all the records those Update field = true :
ForAll(
Filter(collection, Update = true),
If(
IsBlank(ThisRecord.ID),
Patch(
DataSource,
Defaults(DataSource),
{Field1:...,Field2:...,Field3:...,...}
),
Patch(
DataSource,
LookUp(DataSource,ID = ThisRecord.ID),
{Field1:...,Field2:...,Field3:...,...}
)
)
)
Hope this helps.
Best regards,
Community Support Team _ Jeffer Ni
If this post helps, then please consider Accept it as the solution to help the other members find it.