Bulk delete a list of objectIDs

I am looking to delete a list of objectIds.

Currently, I use a loop with the Delete Table Object block like this:
image

As it takes a few seconds of run time to do that and calls the DB multiple times, I would love to use the Bulk delete block instead.

I have all my objectIds in a list. Is there a way to do that?

The “Bulk Delete” block accepts a where clause identifying the objects to be deleted. If you know objectId values, you can compose a where clause that looks like this:

objectId in ('objectIdValue1', 'objectIdValue2', 'objectIdValue3')

Regards,
Mark

Thanks @mark-piller, I saw that and tried. I am guessing this is not the standard array format. So I cannot do this or something similar:


where i is a list of objectIds.

Do I need to convert the list to a text string and then transform the text string? or Map through the list of object Ids and compule a text string with (‘objectIdValue1’, ‘objectIdValue2’, ‘objectIdValue3’)?

Or am I thinking about it all wrong?

Hello @Andreas_Marinopoulos

It works for me: https://monosnap.com/direct/K7n3d1xXsHQzSv0OnaPSghoqf1s55T

Regards,
Inna

1 Like

Thanks @Inna_Shkolnaya will do as you do, gradually building up the complexity of the list and see what I am doing wrong, thanks!

Hi @Inna_Shkolnaya, @mark-piller,

Still not working for me.

In the DB I am successful using the query objectId in ('5CF22CB6-F663-414D-936B-F42BBBF1A2CB','5CE8F217-447B-4D88-90A1-D985753FF122')

If I write the Where clause myself in the business logic, it works fine:

But if I use an array of objectIds (which is what I need), it doesn’t work:

I get:

Because presumably it needs (‘objectId1’,‘objectId2’) instead of (objectId1,objectId2). Any thoughts?

Application ID: 4A47197B-AE30-FA84-FF56-0071F4010900
Method: test

Take a closer look to the request itself.
In the error message it is showed that objectId is not wrapped in a single quotes, so they are treated as keywords.

Indeed. I saw that. But if I have a variable containing a list of objectIds, like Inna has here for example:

Should it work?

Or do I somehow need to use the Map block first to replace the objectId1 in my list with ‘objectId1’ and then it will work?

I think using a loop block will make the logic easier to read and understand later.

I used a loop to complile the text of the where clause. Let me know if anyone has a simpler, more elegant solution.

Hello @Andreas_Marinopoulos

Have you tried to just pass a list as where clause ?

Regards, Vlad

Yeah, not working for me…

I can not see the BulkDelete block in the test method

sorry about that Vlad, I changed it since the comment, let me recreate it one sec.

thanks, you can create it as method test2 =)

I fixed test, just brought it back from the changelog

yeah, but it is not what I meant, take a look at the difference

Perfect, thanks!