Desperately finding a solution to delete rows in Collections

Hi,

Can you please help me.

I run a fashion website. I have 10 collections, each collection has near 8000 items. (8000 rows) Every couple of weeks I need to delete all the items (Rows )in each collection ( Sandbox and Live) and import new items.

At the moment I spend days purely highlighting rows and clicking the delete button. I am absolutely exhausted when it is all deleted.

I followed the instructions shown in these two links, but still no luck.

This is what I did:-
1)Opened a New page
2) Added a Dataset
3) connected the Dataset to “Dresses” (Collection Name)
4) Added the code

export function deleteAll_onClick(event, $w) {
let dataset = $w(" #dynamicDataset "); // or the name of your dataset
dataset.onReady( async () => {
while (dataset.getCurrentItem()) {
await dataset.remove(); } });
dataset.refresh();
}

  1. Pressed preview

When I go to the Dresses Collection all the items are there. Not deleted.


Clicked preview

Please tell me what I am doing wrong here.

Really appreciate your advice.
I have a very little knowledge about coding, so can you please write things down step by step. or with images.
Many thanks.

I think it is a permission thing, maybe you have setup permission to not permit DELETE. Right click your Data Collection and make sure you have the correct permissions.

Thank you Andreas for your reply.

I clicked on “Dresses” “Edit permissions” this is what is see.

Is this correct?

Just try to change DLETE to Site Member and click Preview and see if that works.

That is not not working either. Do you think I have entered the code in the right place? just noticed a red dot.

I do not know what to do…

Hey
On line 12 you have one } to much I guess. Take that out.

I have deleted } as well. red dot disappeared. Thank you. Still items not deleted.
Can you kindly look at the image below and tell me where exactly i need to paste the code:
I thought to start from the beginning.

So, I have a collection called Dresses, and have created a Dynamic page - Dresses
Then I created a another page under menu called Dresses

I created a new page
Added a dataset, connected to Dresses collection. Which is the image you see below.

if you click Manage Dataset on the dataset what rights do you have there? Read or read & Write?

Read and Write

In the properties, under which event do i need to paste the code?

I spend whole day yesterday trying to find and answer and since this morning. I am very grateful for your messages.

maybe I am not entering the code in the correct place.
If it is possible can you please write down the instructions step by step. Many thanks.

Thanks Andreas,
I sent a message yesterday to "Yisrael " as i copied the code that he provided. He has not mentioned where to paste the link. Haven’t heard anything from him yet. I could be pasting the link in the wrong area.

There a no videos on YouTube either about deleting rows on collection.

Was this issue resolved and solution available as we are facing the exact problem. Desperately looking for solution.

This is an old thread. Please repost your question so that you’ll have a better chance of getting answers.