Delete all the rows in a data talbe

I am trying to clear a data table, much like the API call to clear a contact list. I am having no luck at all.
is there anyway to clear all the rows in a data table using a flow and/or an action(s) ?

I have considered updating the table with a CSV to replace, but looking at the APIs for that, its a bit out of my league.

Any idea on how this can be achieved?

thanks
Nick

Hi Nick

After looking at the APIs, it seems the simplest approach is to use the endpoint GET /api/v2/flows/datatables/{datatableId}/rows to retrieve all the row identifiers, and then loop through each while calling out to DELETE /api/v2/flows/datatables/{datatableId}/rows/{rowId} to remove them from the data table.

Have you tried to implement this approach in a data action?

-Charlie

Thanks for your help, this is what I would like to do, yes. I actually am using both at the moment for getting specific row and deleting specific rows with a data table lookup. What I can’t figure out is how to retrieve the data and use the flow to remove it. How to get the data back with the GET. I can run that call, even built an action, it you don’t ask for input it gives you all the key values, and that’s great. Now the part I can’t figure out is how to now pull the result of the get and perform the delete. I will be working on that part today.

This is how I am successfully using the action today for the delete, it needs a key from the table to perform the delete, so I must figure out how to get the result of the GET and apply that to the delete programmatically. I tried a string Contains(".com","") to get a key from the data table lookup and apply that to the key for the delete, no joy. I think I am going about this the wrong way and not using the get and the delete properly for the mass cleanup loop.

I think this image may be a bit better.

Hi @NickCal,

I have a quick question: are you hardcoding the datatable id in your data action definition? This is because the Delete API endpoint requires 2 inputs: datatableId and the rowId that you intend to delete.

DELETE /api/v2/flows/datatables/{datatableId}/rows/{rowId}

If the Email.Message.from matches one of the rowIds, the corresponding row should be deleted.

You mentioned a GET request where you have all the keys, I don't see it in your architetct. How are you getting those rowIds to loop over them?

Best Regards,

Charaf

Thank you for your help, here is what I am using, and it will delete the row for the Email.Message.From, no problem. this is the string I am using in the delete action. /api/v2/flows/datatables/ec13f300-eec9-4d38-9a8d-8ca9937053e3/rows/${Input.Key}. the GUID for the table is static. As for the GET, I am just looking at that in the action at this point.
This works just fine for the flow I sent you, my issue is how can I use the Key in the lookup to just get the next row? The Email.Message.From is only giving me the active FROM address for this interaction. I am comparing that to the table to make a decision as to delete ot

I am a bit of a newbe at this part of the Architect, but I know it can be done, I just am not that smart (yet).

Hi @NickCal,

Here is a way to achieve what you're looking for, which involves either clearing or deleting all rows of a given data table.

The first step is to get all the row keys of the data table. To do this, you can make an API request to the following endpoint:

GET /api/v2/flows/datatables/{datatableId}/rows

All you need to define in the data action for making the above request are:

  • One input: where you specify the ID of the data table.
  • One output: an array containing all the row keys of that particular data table.

Now, you can invoke this data action within your Architect flow. It will return an array of keys. You would need to iterate over each key and call the Delete data action.

Below is a screenshot of a basic flow in which I successfully looped over all the rows and deleted them.

Focus on Delete Data Action block:

Notes:

  • As a precaution, I added a decision block to check if the data table actually has some data. This is done by using the Count() function on the keys array. If, for some reason, the data table is empty, there's no need to enter the loop or call another API endpoint.
  • Regarding the loop, the maximum loop count is set to Count(flow.keys) to ensure you iterate over the entire array. For each key, the Delete data action is passed the key itself by using the GetAt() function.
  • All the Set Participant Data are used for logging purposes [optional].

I didn't take into account pagination if the data table stores a large number of rows. However, this is a simple flow to help you get started.

If you're interested, I've included the data action below.
Delete-Row-in-Data-Table-20230823214329.custom.json (976 Bytes)
Get-Data-Table-Rows-20230823214319.custom.json (1.2 KB)

Let me know your thoughts.

Best Regards,

Charaf

Thank you for the data action and thanks everyone for all your help. I'll let you know how it goes, should go very well now.
regards,
Nick

2 Likes

I will have this done tonight, if successful, the next round of virtual beers is on me !
regards,
Nick

This works great! I am going 1 step further. Because we have 10 cases that this needs to be applied to, I am going to use set/get for the table guid and a schedule for each case and goto this external flow so I dont have to build this and add it to each case. The only issue I run into is to invoke the case flow so it sees the schedule. If I run this at say, 1AM CST that will mean I need an email to invoke it.

Seems my grand plan has a snag. Any idea on how I can invoke the flow so that it hits the schedule ? What I need is a schedule that starts an invoke with an email that does not come from a customer.

Hello, I added another section to this so I can run multiple clearing as (I have 10 tables to clear. This way it keeps me from duplicating this and I dont need to make static data actions for each of the GUID.
thanks for your help.
regards,
Nick


Well, I am going live tomorrow and I ran my first test with a few tables with several hundred entries. I cant seem to get it to clear all the records, each time I rerun it it will only clear 25 records at a time in each table.
Am I running into a limit? I seem to recall a 50 query limit but is that per second or minute ???

When I did my tests I only have about 10 to 15 records in it. Bummer.

any help is appreciated.
thanks
nick

Genesys found what the problem was late last night. The page size default is set to 25.
here is the link

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.