Deleting all or many records from a datasheet

Hi

What is the quickest way of deleting all records (or maybe a subset based on a view)?

If I display 7224 records and click the select all It will only allow me to delete the records that have come into view, not all 7224.

Is there another way to do this, I do not want to delete the datasheet as it has automations associated to it.

Thanks

Hi @Ben_M , thanks for bringing this up. This is due to pagination behavior, I’ve passed your feedback to the product team for review. They’ll evaluate whether improvements are needed.

For now, records need to be deleted in batches manually. While the API supports bulk deletion, it may not be the best fit if you’re not using custom scripts.

Appreciate your understanding.

Thanks Thea

Can you give me a script that I could use in a scheduled/manual automation?

I have tried many different ways but always get errors; an example of this would be:

// Hardcoded IDs
const spaceId = “XXX”;
const datasheetId = “YYY”;
const viewId = “ZZZ”;

// Fetch space, datasheet, view, and delete records
context.space.getSpace(spaceId).then(space => {
space.getDatasheet(datasheetId).then(datasheet => {
datasheet.getView(viewId).then(view => {
view.getRecords().then(records => {
const deletions = records.map(record => datasheet.deleteRecord(record.recordId));
Promise.all(deletions).then(() => {
return {
deleted: records.length,
message: Deleted ${records.length} records from view '${viewId}' in datasheet '${datasheetId}'
};
});
});
});
});
});

Hi @Ben_M , writing scripts like this isn’t my strongest area either. I’ve tried using GPT to help, but it’s still a bit tricky. @Kelvin will be following up on this issue.

In the meantime, these resources might be helpful:

:blue_book: Bika API Docs – Delete Records: Bika OpenAPI Reference | Bika.ai

:wrench: Developer Guide – OpenAPI Overview: OpenAPI Quick Start | Bika.ai

Appreciate your patience as we continue improving Bika.

Hey @Ben_M ,

Based on your code, you’re trying to filter records through a view and delete them in a loop, right? That makes sense! You could try using the Delete Database Multiple Record API for batch deletion. Since this API is new, it’s not in the SDK yet. Here’s a curl example:

curl --location --request DELETE 'https://bika.ai/api/openapi/bika/v1/spaces/{YOUR_SPACE_ID}/resources/databases/{YOUR_DATABASE_ID}/records?records={RECORD_ID_1}&records={RECORD_ID_2}' \
--header 'Authorization: Bearer {YOUR_BIKA_API_KEY}'

Just pass the record IDs as an array via query parameters. Heads-up: this API handles max 100 records per call, and URL length limits might break if the IDs are super long. Maybe split batches if needed!

Hi Kelvin

I was trying to use an automation with a script in that if i provide the SPACE, DATASHEET and VIEW then delete all records in that view. This is only until I can select all records properly.

Would my method not work?