How to know if a list is empty | Community
Skip to main content
April 13, 2023
Solved

How to know if a list is empty

  • April 13, 2023
  • 6 replies
  • 1506 views

Hello,

I'm working on a workflow where I have to purge lists. I'd like to know if there is a way to know if a list is empty (while still keeping its structure).

Best regards,

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by akshaaga

@mtraverso1,

You can use the built-in @COUNT function to count the number of records in the list. If the count is 0, then the list is empty.

Here are the steps to check if a list is empty:

  1. Create a new query activity in your workflow and select the list you want to check.
  2. In the query editor, add a new expression column and enter @COUNT() as the expression. This will count the number of records in the list.
  3. Save the query and run it.
  4. Once the query is finished, open the console tab in the workflow and look for the output of the query. If the count is 0, then the list is empty.

If the count is greater than 0, then you can use a separate activity, such as a delete data activity or a purge data activity, to remove the records from the list.

By using this method, you can check if the list is empty while still keeping its structure intact.

6 replies

SatheeskannaK
Community Advisor
Community Advisor
April 13, 2023

Hi @mtraverso1,

 

After the read list activity, Use a test activity to check the record count on the list. Example condition: vars.recCount >0 

Thanks, Sathees
alnavarg
Level 4
April 14, 2023

Hi @mtraverso1 

 

This is my actual workflow that does this:

 

The first two steps are self-explanatory. The query is just querying the same record set for 0 records, but I also put all the additional data onto the schema that came off the schema when I first loaded it. I think this is so the new List has the exact same structure as the old list. Make sure you put the targeting dimension on there too.

 

Then I just save the new list as the same name as the old list

 

 

 

ParthaSarathy
Community Advisor
Community Advisor
April 17, 2023

HI @mtraverso1 ,

If you want to purge the list and need to insert the new records, you can enable 'Purge and reuse the list if available' option in List Update activity.

 

Or if the requirement is to check whether the data is available in a list, and If yes, then you need to purge all records in the particular list and keeping the same structure in it, then you can try the below workflow set up

Read List: Select your List

Test activity: As mentioned by Sathees, you can use vars.recCount > 0 to split based on record count.

Split Activity on records available transition:

Limit the selected records > Activate random sampling > Limit Maximum size: 0 > Finish

In List Update, Select the same List and enable purge the list checkbox.

So now the workflow checks whether your List has any records, And if records exist, then it will purge the list data but the structure of the list will be same as before.

 

~  ParthaSarathy S~  Click here to join ADOBE CAMPAIGN USER GROUP for Quarterly In-person | Hybrid | Virtual Meetups
CampaignerForLife
Level 5
April 17, 2023

Try to use an JS Activity that tries to retrieve the value 0 of the list 

 

akshaaga
Adobe Employee
akshaagaAdobe EmployeeAccepted solution
Adobe Employee
April 21, 2023

@mtraverso1,

You can use the built-in @COUNT function to count the number of records in the list. If the count is 0, then the list is empty.

Here are the steps to check if a list is empty:

  1. Create a new query activity in your workflow and select the list you want to check.
  2. In the query editor, add a new expression column and enter @COUNT() as the expression. This will count the number of records in the list.
  3. Save the query and run it.
  4. Once the query is finished, open the console tab in the workflow and look for the output of the query. If the count is 0, then the list is empty.

If the count is greater than 0, then you can use a separate activity, such as a delete data activity or a purge data activity, to remove the records from the list.

By using this method, you can check if the list is empty while still keeping its structure intact.

Sukrity_Wadhwa
Community Manager
Community Manager
April 26, 2023

Hi @mtraverso1,

Were you able to resolve this query with the help of the given solutions or do you still need more help here? Do let us know. In case the given solutions were helpful, then kindly choose the one that helped you the most as the 'Correct Reply'.
Thanks!

Sukrity Wadhwa