cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
powerNewbie
Level: Powered On

Unusual Collect function behavior

Hi everyone.

I have a problem with Collect function. Basically application is collecting user's weekly reports. User enters the data and adds it in the collection which is the same structure (same column names) as the backing table (Excel). After entering all data, users hit submit button which after all saves collection to excel table - Collect(excel-table, collection). It works perfectly, without problems. But I add functionality that user can overwrite collection with data from excel-table from previous week, so that user doesn't have to much efforts in populating new week reports. The data copying from excel-table to collection is done without problems. User continue to update data in collection and when it hit submit again as previously stated - Collect(excel-table, collection) it doesn't store it in excel-table. One more scenario: user pulls data from previous week, update that record in collection and then add another record; when it hit submit it only store that new added record from collection, instead both records (I consider copied data from excel-table  to collection as new record to ad when the Collect(excel-table, collection) is called).

Am I missing something with the kind I am using Collect() or there is a bug in back end with Collect function?

1 REPLY 1
dynamicsedge
Level 10

Re: Unusual Collect function behavior

@powerNewbie 

 

We do not think there is a bug here in this case.

 

We think it could be because you are attempting to "update" a record using the Collect function.

We think this is the case due to your own wording. You seem to expect a record to be updated when using the Collect function. However the Collect function is not for updating existing records, but only for creating new records.




That's also probably why you may be experiencing only seeing "Created / brand new" records using Collect.

 

You would want to use the Update function to update a record.

 

From:

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-update-updateif

 

Use the Update function to replace an entire record in a data source. In contrast, the UpdateIf and the Patch functions modify one or more values in a record, leaving the other values alone.

 

From:
https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-clear-collect-clearc...

Collect

The Collect function adds records to a data source. The items to be added can be:

  • A single value: The value is placed in the Value field of a new record. All other properties are left blank.
  • A record: Each named property is placed in the corresponding property of a new record. All other properties are left blank.
  • A table: Each record of the table is added as a separate record of the data source as described above. The table is not added as a nested table to a record. To accomplish this, wrap the table in a record first.

When used with a collection, additional columns will be created as needed. The columns for other data sources are fixed by the data source and new columns cannot be added.

 

 

 

 

 

Helpful resources

Announcements
Better Together’ Contest Finalists Announced!

'Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Join THE global Microsoft Power Platform event series

Attend for two days of expert-led learning and innovation on topics like AI and Analytics, powered by Dynamic Communities

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

thirdimage

Microsoft Business Applications Virtual Launch

Join us for the Microsoft Business Applications Virtual Launch Event on Thursday, April 2, 2020, at 8:00 AM PST.

thirdimage

Community Summit North America

Innovate, Collaborate, Grow - The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (9,633)