web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Collect Function Rando...
Power Apps
Unanswered

Collect Function Randomly Losing Records

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

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!

Categories:
  • Meneghino Profile Picture
    6,949 on at

    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.

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 234 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 207 Most Valuable Professional

#3
timl Profile Picture

timl 122 Super User 2026 Season 2

Last 30 days Overall leaderboard