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 / Reset Input dropdowns ...
Power Apps
Answered

Reset Input dropdowns creates blank record in SharePoint

(0) ShareShare
ReportReport
Posted on by 127

Hello All! 

 

I barely know what I'm doing, so I'm happy to have gotten this far. I am creating a shopping cart app.

 

First, I collect the data into a Collection (ColCart) and execute it with the "Add to Cart" button. In the {} are the columns I want to patch on my SharePoint List (Orders)

 

Collect(ColCart,{Name: Name.Text, Title: RoomNumberText.Text, Email: Emailtext.Text, DateText: Date1.SelectedDate, Category: drpCategory.Selected.Result, Subcategory: drpSubcategory.Selected.Result, ItemName: drpItemName.Selected.ItemName, Quantity: Quantity.Text})

 

I want the bold columns to be reset on the app, when the person presses the "Add to Cart" button, so they can add more items easily.  I changed it to this (I added the code  that's underlined):

 

Collect(ColCart,{Name: Name.Text, Title: RoomNumberText.Text, Email: Emailtext.Text, DateText: Date1.SelectedDate, Category: drpCategory.Selected.Result, Subcategory: drpSubcategory.Selected.Result, ItemName: drpItemName.Selected.ItemName, Quantity: Quantity.Text});

 

Reset(drpCategory);Reset(drpSubcategory); Reset(drpItemName); Reset(Quantity)

 

Just in case you need this. This is the code for submitting to SharePoint.

Orders = SharePoint List

ColCart = Collection

 

Patch(Orders, Defaults(Orders), { Title: RoomNumberText.Text, DateText: Date1.SelectedDate, Name: Name.Text, Email: Emailtext.Text, Category: drpCategory.Selected.Result, Subcategory: drpSubcategory.Selected.Result, ItemName: drpItemName.Selected.ItemName, Quantity: Quantity.Text});

Collect(Orders, ColCart)

 

The Power App

Screenshot PowerApps.jpg

 

The SharePoint Result

The SharePoint List resultThe SharePoint List result

 

When I delete Reset(drpCategory);Reset(drpSubcategory); Reset(drpItemName); Reset(Quantity), the extra record is not generated.

 

Thank you!

 

Categories:
  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    @Dianez 

    Assuming the gallery on the right side's Items are the collection, then the blank value is being added with your patch executed by the Submit Order button.  You could check that by looking at the collection:  

    !.jpg

    If that is the case, and your collection has the same columns as your Orders list, a simple 

    Collect(Orders, ColCart) should add the cart items to the Orders list without adding another line.  In any event, I would add an error check 

     

    Collect(Orders, ColCart);
    If(
     !IsError(Collect(Orders, ColCart),
     Reset(drpCategory);
     Reset(drpSubcategory);
     Reset(drpItemName); 
     Reset(Quantity)
    )
     
     

    This would guarantee that the resets do not occur unless the addition of the cart is added to the Orders list.

     

     

  • Dianez Profile Picture
    127 on at

    Thank you for your response! I checked the collection and the extra blank record does not exist in it.

    I tried the formula and it did not work. I should clarify that I am trying to reset the input fields after the "Add to order" button is pressed.

     

    But, like you said, since the Collection does not have the extra record in it, it's probably an issue with the patch function. I also tried to put this in the patch formula: 

     

    Remove(ColCart,LookUp(ColCart, ItemName=""))

  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    @Dianez 

    I use Collect(colDS, Defaults(datasource)) ;Clear(colDS) to initialize my collection.  The Clear() removes the blank record that the Collect() adds to the collection.  This guarantees that all the columns and the schema of the collection exactly matches the datasource. Then, when the collection is appended to the datasource, a simple 

    Collect(datasource,colDS) is all that is needed. 

  • Dianez Profile Picture
    127 on at

    Okay an update after that last message. I tried this function in the patch and I removed all the records that contain data leaving only the blank one, lol. 

     

    Remove(Orders,LookUp(Orders, ItemName=""))

     

    What's the opposite of this? lol

  • Verified answer
    Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    @Dianez 

    RemoveIf(Orders, ItemName=Blank())

    But IMHO, it would be better to figure out how to prevent the blank from being added

  • Dianez Profile Picture
    127 on at

    It worked! Thank you so much!! I put this in the patch function for the Submit button and it worked. Thank you so much!

  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    You're Welcome!You're Welcome!

     

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 354 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 330

#3
Mohsin Ali Profile Picture

Mohsin Ali 232

Last 30 days Overall leaderboard