Automatically deleting records based on a query

I have a query that Identifies orphaned records in a table.
There are around 2000 records that need to be deleted. I know how to delete them individually
I wondered if there is a way of deleting them all in one go?
Could you point me in the right direction please

You can pass the results of the query to the delete record step.

is there a tutorial on how to do this? I have been trying all day with no success

there’s no tutorial about this specific case, but it’s quite simple.
In the delete record step you need to pass an array of the ids you want to delete. To do that, select your query as an expression, use the flatten formatter and select the property (id) that you want to pass to the delete step. Use the IN condition, as the value is an array:

For some reason this does not work,
at least I was on the right track,

I have followed your example to the letter.

I am trying to trigger the delete using an on click event from a button on the page, don’t know if that makes a difference? I hope i have not missed something really obvious.

Well are you sure your query returns any values? You can output both steps and see the results in the browser dev tools.

The query is outputting the correct values

in the browser dev tools it is saying 414 requested uri is too large

How do you know that if you see an error?
Are you sure you are looking under Network > XHR when the server action runs?

I set it to auto load and it worked perfectly as soon as the page loaded. It must have been something to do with the on click action.

I will continue to experiment thanks for the help