How to create a workflow to delete items from a list that satisfy a specific condition?

Last Update: December 21, 2018

Apply for: SPARK Workflow for SharePoint 2013/2016 and Office 365

Suppose you have a list named "List1" and you want to create a site workflow to delete all items from this list where the column "Title" equals to "S123".
How to create a workflow to delete items from a list that satisfy a specific condition1.png
Here are the steps on how to do that.

  1. Create a new list workflow. For more details on how to create a list workflow, refer to Create a list workflow use case.
  2. Drag "For Each" and "Delete Item" activities onto the workflow canvas and drop it onto a design node as follows:
    How to create a workflow to delete items from a list that satisfy a specific condition2.png
  3. Configure the "For Each" activity as follows:
    How to create a workflow to delete items from a list that satisfy a specific condition3.png
    Note: A workflow variable of type integer should be created to store the value in when looping through each value in the list.
  4. Configure the "Delete Item" activity as follows:
    How to create a workflow to delete items from a list that satisfy a specific condition4.png
  5. Publish the workflow by clicking on the Publish button in the workflow ribbon.
  6. Now go to "List1" and run the workflow. For more details on how to run a list workflow, refer to Run a list workflow use case.
  7. After completing running the workflow, you will see that all items in the list that satisfy the condition have been deleted from the list.