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() in dynamic g...
Power Apps
Answered

Collect() in dynamic gallery adding duplicate rows when the values are edited

(0) ShareShare
ReportReport
Posted on by 34

Hi all, I've made a management system with dynamic fields and values. When new records are inserted it is working fine but when I want to change any value in my collection before submitting to Sharepoint, it is creating duplicate rows with updated values. Duplicates values are causing trouble for me. I've used OnChange trigger to fill values in collection. Please help me to find solution. Thanks

issue.png
Categories:
I have the same question (0)
  • SebS Profile Picture
    4,746 Super User 2026 Season 1 on at

    @MisbahKhwaja 

     

    You did not specify record

     

    in your screen you pointing to collection than you only did condition but when condition is meet you need point to record

     

    UpdateIfDataSourceCondition1ChangeRecord1 [, Condition2ChangeRecord2, ... ] )

  • MisbahKhwaja Profile Picture
    34 on at

    I'm using this to insert updated values in collection

    {BehManComment: ManagerComment_6.Text}

    but it is creating two rows of updated value.

  • SebS Profile Picture
    4,746 Super User 2026 Season 1 on at

    @MisbahKhwaja 

     

    it will be helpful if You past your code rather do screen of it.

     

    UpdateIf(colbehavioralEvalist, 
    BEID = Lable_6.Text,//Condition
    Value(Lable6.Text)//<---Record
    {BehManComment: ManagerComment_6.Text}) // Update
  • MisbahKhwaja Profile Picture
    34 on at

    Here is my code
    Collect(
    colBehavioralEvaList,
    {
    BehDes: Description_6.Text,
    BehRating: Rating_6.SelectedText.Value,
    BehManComment: ManagerComment_6.Text,
    BehEmpComment: "",
    BEID: Label1_6.Text
    }
    );

     

    UpdateIf( colBehavioralEvaList, BEID = Label1_6.Text, {BehManComment: ManagerComment_6.Text});

  • SebS Profile Picture
    4,746 Super User 2026 Season 1 on at

    @MisbahKhwaja 

     

    So if BEID is not ID of the record you need to find it, same as SharePoint Collection create them own ID

     

    UpdateIf( 
     colBehavioralEvaList,
     BEID = Label1_6.Text,
     Lookup(colBehavioralEvaList,BEID = Label1_6.Text,ID),
     {
     BehManComment: ManagerComment_6.Text
     }
    
    );
  • SebS Profile Picture
    4,746 Super User 2026 Season 1 on at

    @MisbahKhwaja 

     

    The real question is how You using this and what validating the condition ?

    do You have a form or something and if the form is in edit mode You than Updating ?

    or how this works ?

     

    if you have both code in one button that do not have much sense or I'm thinking it wrong

  • MisbahKhwaja Profile Picture
    34 on at

    BEID is my record ID. Label1_6 = ThisItem.ID. 

  • Verified answer
    SebS Profile Picture
    4,746 Super User 2026 Season 1 on at

    @MisbahKhwaja 

     

    I think this should work better

     

    so in this scenario You checking if BEID exist if not You collecting and if it exist You patching update

     

    If(IsBlank(Lookup(colBehavioralEvaList,BEID = Label1_6.Text,ID)),
    Collect(
    colBehavioralEvaList,
    {
    BehDes: Description_6.Text,
    BehRating: Rating_6.SelectedText.Value,
    BehManComment: ManagerComment_6.Text,
    BehEmpComment: "",
    BEID: Label1_6.Text
    }
    ),
    Patch(colBehavioralEvaList,
    Lookup(colBehavioralEvaList,BEID = Label1_6.Text,ID),
    {
    BehManComment: ManagerComment_6.Text
    }
    )
    )
     
    
  • SebS Profile Picture
    4,746 Super User 2026 Season 1 on at

    @MisbahKhwaja 

     

    If You updating / patching to record what you hold in gallery there is even easier way.

    assuming your button is outside of the gallery you can do something like that

     

    Patch(colBehavioralEvaList,
    GalleryName.Selected,
    {
    BehManComment: ManagerComment_6.Text
    }
    )

     

    but if you collect and update under same button you need to create something what will let the function know when to do the task.

     

    If you collect first and than update you will duplicate the record as every time it will first create new record and than update it but you do not see the update 

     

  • Ethan_009 Profile Picture
    4,838 Moderator on at

    Hi @MisbahKhwaja ,

     

    To ensure duplicate records aren't created, use the following code:

    If(
     ThisItem.ID in colBehavioralEvalist.BEID,
     Update(
     colBehavioralEvalist,
     {
     BehDes: Description 6.Text, 
     BehRating: Rating 6.SelectedText.Value, 
     BehManComment: Manager Comment_6.Text,
     BehEmpComment: ""
     }
     ),
     Collect(
     colBehavioralEvalist,
     {
     BehDes: Description 6.Text, 
     BehRating: Rating 6.SelectedText.Value, 
     BehManComment: Manager Comment_6.Text,
     BehEmpComment: "",
     BEID: Label1_6.Text
     }
     )
    )

     

    Hope this helps

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Apps

#1
wolenberg_ Profile Picture

wolenberg_ 119 Super User 2026 Season 1

#2
WarrenBelz Profile Picture

WarrenBelz 107 Most Valuable Professional

#3
Haque Profile Picture

Haque 103

Last 30 days Overall leaderboard