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( patching to c...
Power Apps
Answered

Collect( patching to collection creating blank item/row after first item added

(0) ShareShare
ReportReport
Posted on by 1,599 Super User 2024 Season 1

Hello,

When I am adding items to a collection, when the first item is added, it also creates a blank row above it in the collection, however when additional items are added, no further blank rows are created.


As you can see from my gallery, there is a blank row at the top - the data source of my gallery is my collection:

sudosaurus_0-1693430607110.png

This is also visible in my Collection variables:

sudosaurus_1-1693430657250.png

A button I use to add this data into my collection uses this fx:

Collect(colTopicClaim, {Topic: Topic_dd.Selected.Value, TopicRAGStatus: TopicRAGStatus_dd.Selected.Result, Claim: Claim_TextInput.Text});
UpdateContext({varTopicClaim: false})

It's also worth noting that my collection is created from a previous screen with this fx:

NewForm(DocData_form);ClearCollect(colTopicClaim, {Topic: "", Claim: "", TopicRAGStatus: ""}) ;Navigate(FormScreen,ScreenTransition.Cover)

Ideally, Id like to use this fx on the button that saves data to my collection - this includes 'ThisItem' however when doing so, creates two blank rows in the collection along with the row with data (so 3 rows in total!)

Collect(colTopicClaim, ThisItem, {Topic: Topic_dd.Selected.Value, TopicRAGStatus: TopicRAGStatus_dd.Selected.Result, Claim: Claim_TextInput.Text});
UpdateContext({varTopicClaim: false})

 I've also tried using Patch instead of Collect and this causes the same kind of duplication!

 

Any pointers would be really helpful.

 

Thanks. 

Categories:
I have the same question (0)
  • SpongYe Profile Picture
    5,715 Super User 2026 Season 1 on at

    Hi @sudosaurus 

     

    Looks like the ClearCollect is causing the problem change this

    NewForm(DocData_form);ClearCollect(colTopicClaim, {Topic: "", Claim: "", TopicRAGStatus: ""}) ;Navigate(FormScreen,ScreenTransition.Cover)

    To this:

    NewForm(DocData_form);Clear(colTopicClaim);Navigate(FormScreen,ScreenTransition.Cover)

     

    And then the empty row will disappear.

     


    ------------------------------------------------------------------------------------------------------------------------------
    If I have answered your question, please mark your post as Solved. Remember, you can accept more than one post as a solution.

    If you like my response, please give it a Thumbs Up.

  • sudosaurus Profile Picture
    1,599 Super User 2024 Season 1 on at

    @SpongYe that won't work as I need to include {Topic: "", Claim: "", TopicRAGStatus: ""} to create the blank columns in my collection.

    As I have this small gallery/form that includes these fields - changing the fx to what you suggested, stops these fields from showing in the gallery. 

    sudosaurus_0-1693431972278.png

    The "Add Topic" button above includes this Fx:

    Collect(colTopicClaim, ThisItem, {Topic: Topic_dd.Selected.Value, TopicRAGStatus: TopicRAGStatus_dd.Selected.Result, Claim: Claim_TextInput.Text});
    UpdateContext({varTopicClaim: false})

     

  • SpongYe Profile Picture
    5,715 Super User 2026 Season 1 on at

    You need to a check when adding a topic if the colomns are empty and remove the empty row.

    Because of this {Topic: "", Claim: "", TopicRAGStatus: ""} collection creates a blank row.

     

    What we can do is change the "Add Topic" button Fx with:

    RemoveIf(colTopicClaim, Topic = "" And TopicRAGStatus = "" And Claim="")

     

    Looks like in the code:

    RemoveIf(colTopicClaim, Topic = "" And TopicRAGStatus = "" And Claim="")
    
    Collect( 
     colTopicClaim, 
     ThisItem, 
     {
     Topic: Topic_dd.Selected.Value, 
     TopicRAGStatus: TopicRAGStatus_dd.Selected.Result, 
     Claim: Claim_TextInput.Text
     }
    );
    
    UpdateContext({varTopicClaim: false})

     


    ------------------------------------------------------------------------------------------------------------------------------
    If I have answered your question, please mark your post as Solved. Remember, you can accept more than one post as a solution.

    If you like my response, please give it a Thumbs Up.

     

  • sudosaurus Profile Picture
    1,599 Super User 2024 Season 1 on at

    @SpongYe - so I noticed that the blank record is created when going to the edit screen:

    sudosaurus_0-1693433515454.png

    I added the above change of fx to the "Add Topic" button however the blank record is not removed.

    sudosaurus_1-1693433606663.png

  • Verified answer
    SpongYe Profile Picture
    5,715 Super User 2026 Season 1 on at

    Can you try the RemoveIf on a simple button see if it works. 

    Because it should remove the rows that are blank. 

     

    ------ Only try this if the above doesnt work.

    If that doesn't work we need to try using Blank() instead of "". 

    Than need to make these changes:

    NewForm(DocData_form);ClearCollect(colTopicClaim, {Topic:Blank(), Claim:Blank(), TopicRAGStatus:Blank()}) ;Navigate(FormScreen,ScreenTransition.Cover)

     And then the removeIf also changes:

    RemoveIf(colTopicClaim, Topic=Blank() And TopicRAGStatus=Blank() And Claim=Blank())

     

     

    Tested it myself:

    Created a collection via a button:

    Collect(colTopicClaim, {Topic:"",Claim:"",TopicRagStatus:""})

    And then I have a RemoveIf button:

    RemoveIf(colTopicClaim, Topic="" And Claim="" And TopicRagStatus="")

     Its working for me. After adding 3 empty rows:

    PowerYsa_1-1693435008812.png

    End result is:

    PowerYsa_2-1693435048794.png


    ------------------------------------------------------------------------------------------------------------------------------
    If I have answered your question, please mark your post as Solved. Remember, you can accept more than one post as a solution.

    If you like my response, please give it a Thumbs Up.

     

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
WarrenBelz Profile Picture

WarrenBelz 531 Most Valuable Professional

#2
Haque Profile Picture

Haque 261

#3
Kalathiya Profile Picture

Kalathiya 221 Super User 2026 Season 1

Last 30 days Overall leaderboard