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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Clearing shopping cart...
Power Apps
Unanswered

Clearing shopping cart/gallery with a button

(0) ShareShare
ReportReport
Posted on by

I've created a simple order form app. I followed Shane Young's ideas at setting up a shopping cart type app. On one page I call "shopping cart" it displays in a gallery the items they have selected on previous pages. I was able to set up a trash can icon right next to each gallery item that removes them, but I'm looking for two things:

 

1) A button at bottom of page that will clear all their items in that gallery. I have tried Reset(BrowseGallery2) to no effect.

 

2) I'd like a way for after they have submitted their order (a button I've created using Shane Young's ideas to populate a Sharepoint list/collection), for it to clear out their gallery and return them to the main page. I got the Navigate down, and even tried Reset(BrowseGallery2) here as well in the OnSelect, but it will navigate away, but not clear anything out.

 

I'm not sure how to do all this. Plus, I'm not sure how post more details here for y'all to see what I'm talking about.  Thanks for any help you can offer!

Categories:
I have the same question (0)
  • StalinPonnusamy Profile Picture
    Super User 2024 Season 1 on at

    Hi @Anonymous 

    Reset(BrowseGallery2) is clear the selection. We have to Clear(CollectionName) which clears the data from the collection since the gallery data source is collection.

  • Community Power Platform Member Profile Picture
    on at

    Hi @StalinPonnusamy , hope this finds you well.

    May I know at which property or where exactly do I need to use Clear(CollectionName)? Because I am experiencing quite the same issue here. 

  • AndrewR1 Profile Picture
    1,572 Moderator on at

    Hi @Anonymous Clear(CollectionName) would go in the on Select Property of your trash icon as long as you are using a collection not a SP list for the Cart this will work for you. 

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. Remember, you can accept more than one post as a solution. If the content was useful in other ways, please consider giving it Thumbs Up.


    Thanks
    Andrew



  • Community Power Platform Member Profile Picture
    on at

    Hi @AndrewR1,

    I am sorry for the confusion but in my case, I would like to clear my Cart once a user click on "Submit Order" button. Do I put Clear(CollectionName) in each + icon of each tool because as for now, this is what the OnSelect of + icon looks like:

     

    Collect(
     SelectedTools,
     {
     Item: RawPCBNo_2.Text,
     Details:Model_2.Text
     }
    )

     

    Do I need to modify the code to this?:

     

    ClearCollect(
     SelectedTools,
     {
     Item: RawPCBNo_2.Text,
     Details:Model_2.Text
     }
    )

     

     

    And on the Submit Order button, I just have Patch and Notify function at OnSelect property and its working fine. 

     

  • AndrewR1 Profile Picture
    1,572 Moderator on at

    Hi @Anonymous no using collect is the right way to do this as you want to keep the last selection in the collection the code you have used is fine!

     

    Correct Code for the + icon: 

     

     

    Collect(
     SelectedTools,
     {
     Item: RawPCBNo_2.Text,
     Details:Model_2.Text
     }
    )

     

     

     

    I would then add Clear(Your Collection) to the end of the on select property of the submit button this will clear once the user has submitted! 

     

    On Select property of your Submit Button: 

     

    Your Submit Function;
    Clear(SelectedTools)

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. Remember, you can accept more than one post as a solution. If the content was useful in other ways, please consider giving it Thumbs Up.


    Thanks
    Andrew

  • Community Power Platform Member Profile Picture
    on at

    @AndrewR1 

    It works! Thank you, I appreciate your help so much! 

  • AndrewR1 Profile Picture
    1,572 Moderator on at

    Hi @Anonymous that's awesome I'm glad that I helped you get it working! Could you accept my last reply as the solution for this case as this will then close the case and other with the same issue can easily find the solution for this? 🙂

     

    Many Thanks 

    Andrew 

  • Community Power Platform Member Profile Picture
    on at

    @AndrewR1 I am not the original post author so I don't have the ability to do that. I am sorry.

  • AndrewR1 Profile Picture
    1,572 Moderator on at

    @Anonymous of course my apologies mate! Have a great day! 

     

    Andrew 🙂

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard