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 / Inconsistent records i...
Power Apps
Suggested Answer

Inconsistent records in collection

(1) ShareShare
ReportReport
Posted on by 2
Hi Everyone,
                       We are experiencing an intermittent issue in our Power Apps canvas application. When records are added to a collection from the OnChange event of a text input control, the record is not consistently inserted into the collection. The issue occurs randomly and cannot be reproduced consistently.
 
Application Type: Canvas App.
Since When: We are unable to determine exactly when the issue started, as it occurs randomly and intermittently.
Scenario: The issue occurs randomly. The same functionality works correctly most of the time, but occasionally the OnChange event does not add the record to the collection. There is no consistent pattern to reproduce the issue.
 

Thank you for your support.

Best regards,
Gnanasekar.V

 
Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    156,098 Most Valuable Professional on at
    Can you please post the Patch code you are using OnChange of your control.
  • Suggested answer
    oyepanky Profile Picture
    563 on at

    Hi @Gnanasekar,

    Intermittent issues like this are often caused by the OnChange event not firing consistently (for example, if the value doesn't actually change or the control loses focus unexpectedly). Could you please share the OnChange formula you're using (especially the Collect() or Patch() code) and let us know if the issue occurs on the web, mobile, or both? That will help narrow down the cause.

    Best Regards,
    Pankaj Jangid (OyePanky)
    Power Platform Developer
    YouTube: https://www.youtube.com/@oyepanky
    Website: https://dialforit.com

  • Gnanasekar Profile Picture
    2 on at

    The collect() function used in OnChange is present here, and issues occur on both the web and mobile platforms.

    Collect(

                            GateEntryLine,

                            {

                                PONumber: ThisItem.'Purchase order',

                                LineNo:Text( ThisItem.'Line number'),

                                ItemNo: ThisItem.'Item number',

                                POQty: ThisItem.Quantity,

                                QtyatGate: Value(qtyatgate_2.Text),

                                AssignedLocation: Coalesce(

                                    ThisItem.'Default receipt location',

                                    ThisItem.Location

                                ),

                                Warehouse: ThisItem.Warehouse,

                                RecId: Text(ThisItem.RecId1),

                                Company: ThisItem.Company

                            }

                        ),

                        UpdateIf(

                            GateEntryLine,

                            PONumber = ThisItem.'Purchase order' && LineNo = Text(ThisItem.'Line number'),

                            {QtyatGate: Value(qtyatgate_2.Text)}

                        )

  • timl Profile Picture
    37,262 Super User 2026 Season 1 on at
     
    A common issue is that if a user types text into the control and immediately clicks a button or interacts with some other UI, the OnChange event doesn't fire. 

    If I had to guess, I expect this is the behaviour you're experiencing. If it's possible to not use OnChange, it's generally more reliable to place your Collect or Patch formula in the OnSelect of a button.
     
    There are also known issues with using OnChange on a gallery so you might want to see if this applies to you.
     
     
  • Suggested answer
    oyepanky Profile Picture
    563 on at

    Hi @Gnanasekar,

    Thanks for sharing the code.

    One thing I noticed is that you're calling Collect() and UpdateIf() sequentially in the same OnChange event. Since OnChange can be triggered unpredictably (especially on both Web and Mobile), this may lead to inconsistent behavior.

    Instead of always calling Collect(), consider checking whether the record already exists first, for example:

    If(
        IsBlank(
            LookUp(
                GateEntryLine,
                PONumber = ThisItem.'Purchase order' &&
                LineNo = Text(ThisItem.'Line number')
            )
        ),
        Collect(
            GateEntryLine,
            {
                PONumber: ThisItem.'Purchase order',
                LineNo: Text(ThisItem.'Line number'),
                ItemNo: ThisItem.'Item number',
                POQty: ThisItem.Quantity,
                QtyatGate: Value(qtyatgate_2.Text),
                AssignedLocation: Coalesce(
                    ThisItem.'Default receipt location',
                    ThisItem.Location
                ),
                Warehouse: ThisItem.Warehouse,
                RecId: Text(ThisItem.RecId1),
                Company: ThisItem.Company
            }
        ),
        UpdateIf(
            GateEntryLine,
            PONumber = ThisItem.'Purchase order' &&
            LineNo = Text(ThisItem.'Line number'),
            { QtyatGate: Value(qtyatgate_2.Text) }
        )
    )
    

    This ensures that a new record is only collected if it doesn't already exist; otherwise, the existing record is updated. It may help eliminate the intermittent behavior you're seeing.

    Best Regards,
    Pankaj Jangid (OyePanky)
    Power Platform Developer
    YouTube: https://www.youtube.com/@oyepanky
    Website: https://dialforit.com

  • WarrenBelz Profile Picture
    156,098 Most Valuable Professional on at
    I totally agree with @timl on using a button or icon to update a record in a Gallery rather than expecting OnChange to reliably manage it - let the control "settle down" after the change and then use another one to get all the values. I am also assuming thst is not the full code as it seems to need and If statement above it for the alternate fuctions.
     
    Please Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider answering Yes to Was this reply helpful? or give it a Like
    Visit my blog
    Practical Power Apps    LinkedIn  

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

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 335 Most Valuable Professional

#2
11manish Profile Picture

11manish 165

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 96 Super User 2026 Season 1

Last 30 days Overall leaderboard