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,
Solved! Go to Solution.
Views
Replies
Total Likes
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:
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.
Hi @mtraverso1,
After the read list activity, Use a test activity to check the record count on the list. Example condition: vars.recCount >0
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
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.
Try to use an JS Activity that tries to retrieve the value 0 of the list
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:
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.
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!
Views
Replies
Total Likes