Hello,
I have a simple App that allows users to upload an item that is then added to a spreadsheet and visible on the site.
This seems to all work fine but I am trying to find a way for users to remove their own item if it is has sold/no longer available.
The items are uploaded via the screen below:
And items are then added to a simple spreadsheet
What I ideally want to do is to allow users to click a button on an item page that will then remove a specific item from the spreadsheet (and the app).
I.e. a button on this page that will remove this item
Wondering if anyone has any ideas on how best to approach this?
Thanks,
Jonny
Solved! Go to Solution.
I recommend using @timl's solution above just using Remove() and referencing the record. They'll do the same thing, but if you have a product with the same name for whatever reason, they'll both be removed using the RemoveIf() and the product name.
Hi @Anonymous
Thanks for responding so quickly on this.
Apologies, I’m not that clued up when it comes to PowerApps. So essentially if I added a button on the page would it be something like:
OnSelect -
RemoveIf(CategoriesGallery.Selected.CategoryId)
On the listing page, it uses the following logic:
SortByColumns(Filter(Products, And(CategoryId = CategoriesGallery.Selected.CategoryId,SearchBoxText.Text in ProductName)), If(category = "Reviews", "Comments", "Available"), If(category = "Reviews", Descending, Ascending))
Thanks,
Jonny
RemoveIf() requires a data source and a condition. Your data source is Products and your condition is a matching CategoryId. Therefor, your formula would look like this:
RemoveIf(Products,CategoryId = CategoriesGallery.Selected.CategoryId)
I'll go ahead and also say that the best practice would be to either record this item in a different "RemovedProducts" excel sheet or instead of removing it, add a column called "Active" where a value of 1 or 0 marks whether it is active. (You would then use UpdateIf() instead) That way you don't lose any data unintentionally. RemoveIf() is unforgiving in that the data will be gone if removed.
---
If this answered your question, please click "Accept Solution". If this helped, please Thumbs Up.
Thanks @Anonymous that's really helpful.
Since that removes all items from a category, is there any way to adjust so it just removes a specific product from that category? For example, how could the button remove this exact test?
Thanks,
Jonny
Yes, good question. You'll need a unique ID for that item. How is the test item being displayed in your screenshot?
For example, if your gallery in your screenshot is pulled with Filter(YourData, ItemID = Gallery1.Selected.ItemID) then you could use RemoveIf(YourData, ItemID = Gallery1.Selected.ItemID).
From your screenshot, it seems that ProductId should be the unique identifier for each row in your spreadsheet.
Since this appears to be empty for most of the records, this makes it difficult to build the condition to pass to the RemoveIf function. As an alternative, you could try the Remove function.
Remove(Products, CategoriesGallery.Selected)
This would remove the selected item in the gallery control.
Hi,
I don't think there is a specific ProductId (screenshot below). Could it be done via selected ProductName?
Thanks
Yes, you can use ProductName. The only thing to be careful is that if ProductName isn't unique, you can end up removing more rows than you intend.
RemoveIf(Products,ProductName = CategoriesGallery.Selected.ProductName)
I recommend using @timl's solution above just using Remove() and referencing the record. They'll do the same thing, but if you have a product with the same name for whatever reason, they'll both be removed using the RemoveIf() and the product name.
User | Count |
---|---|
119 | |
86 | |
83 | |
74 | |
69 |
User | Count |
---|---|
215 | |
179 | |
140 | |
109 | |
83 |