Showing results for 
Search instead for 
Did you mean: 
New Member

Collect Function Randomly Losing Records

I have been having a very weird issue with my PowerApp that the client has reported to me, I am unable to replicate it so troubleshooting has been almost impossible.


Basically, I have an app that will record drivers who are working for a company on each day, the parent company then uses the list of drivers that the app captures for payroll.


The user will see a gallary control that lists each driver's name, they will then click a checkbox next to their name if the driver is working. When the user clicks a checkbox, the driver's name is then added to a collection within the app. The collection captures the data perfectly fine every time, no issues there. The app will then take the drivers from the collection, and log them directly to a Common Data Service entity. I also have a success message that will count the drivers just submitted, it is a CountA function on the CDS entity, so the drivers must be submitted for the CountA function to return anything. Through all of my tests the app has worked perfectly.


Recently I have been getting reports of the app "losing" random drivers. Say Bob logs 10 drivers that are working for Company X today, he hits submit and the app displays a success message: "Success, 10 drivers have been logged for Company X". When bob goes into the functionality on the app that allows him to view previous logs, there are only 6 drivers logged for Company X. THis will be true on the backend inside of the CDS entity, only 6 drivers logged. Somehow the CountA function filtered down the drivers table and found 10 records, but in reality, there was only 6.


I have also had reports of the app displaying the wrong display name, so instead of Company X, the message would show Company Z even though the log was for X. I use context variables to capture the company and make sure to clear them when the user starts the app.


Even weirder is it seems to only happen on rare occassions, once a week tops with about 10 different users logging batches of drivers per day. Since I cannot get these issues to replicate even once on my end, I am at a loss as to what may be causing it, so I decided to try here. The code that is responsible for logging drivers is pasted below, if anyone has any ideas on where to start to solve this bizarre issue it would be greatly appreciated. 



If(Value(txtBudgetCount.Text) < Value(txtSelectedCount.Text) && IsBlank(txtGeneralComments.Text) , Error , SubmitForm(Form2); Collect('Driver Logs', cltDriverSelect); RemoveIf('Daily Entity',Entity=EntityFilter); UpdateContext({JustLogged: CountA(Filter('Driver Logs', Entity = EntityFilter, Date = today).Driver)}) ; UpdateContext({SuccessMessage: "Success, " & JustLogged & " Drivers Logged for " & EntityFilter & "!"}); Navigate(Home, ScreenTransition.None, {SuccessMessage: SuccessMessage}))



Thanks everyone!

Community Champion
Community Champion

Re: Collect Function Randomly Losing Records

Hi @lochs38

You should be able to collect the result of the data submission directly if you use a Patch function instead of a collect.

ClearCollect(ResultOfUpdate, Patch('Driver Logs', XXX, cltDriverSelect))

The XXX should be a table with the equivalent of Defaults('Driver Logs') but with as many rows as cltDriverSelect.

Have to dash now, so please let me know if you need clarifications on this.


Then you can inspect ResultOfUpdate directly to see if all is well.


Helpful resources

Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.


Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Tech Marathon

Maratón de Soluciones de Negocio Microsoft

Una semana de contenido con +100 sesiones educativas, consultorios, +10 workshops Premium, Hackaton, EXPO, Networking Hall y mucho más!

Top Solution Authors
Top Kudoed Authors
Users online (7,075)