Delete Items
This custom SharePoint workflow activity is designed to delete items from a specified SharePoint list based on certain filter conditions. It requires a connector to establish the connection to the SharePoint list and a filter to identify which items should be deleted. The activity includes optional parameters for narrowing the search to specific folders and determining whether subfolders should be included in the query. Additionally, the activity provides an output parameter to capture the IDs of the deleted items.
Required parameters:
- Connector The connector used to perform update operations on the SharePoint list. This parameter ensures that the workflow can connect to the specified SharePoint list and perform the delete operation. Usage: Set the appropriate connector to establish a connection to the target SharePoint list.
- SharePoint list The SharePoint list where the items to be deleted are located. Usage: Specify the name or identifier of the SharePoint list from which the items will be deleted.
- Filter list items This parameter specifies the conditions that the items to be deleted must meet. For example, you can filter by certain fields or item properties.
Optional parameters:
- Search in folder This parameter narrows the search to a specific folder in the SharePoint list. If left blank, the query will search the entire list.
- Include subfolders Specifies whether the search should include items from subfolders within the list or folder specified. This parameter is checked by default, meaning subfolders are included in the search. If you do not want the query to include subfolders, uncheck this parameter.
Output parameters: The user can also assign output parameters by selecting a workflow variable, which will receive and store the IDs of the items that were deleted.
Functionality: When the user launches an action with an item removal activity, the first step will be to validate the input data, i.e. check that the required parameters are provided and correct. The next step performed by the activity is to establish a connection to the SharePoint list. The activity then sends a query to the SharePoint list to identify items that meet the filtering conditions specified in the Filter List Items parameter. If the Search in Folder parameter is specified, the query is limited to the specified folder in the list. The Include Subfolders option determines whether items in subfolders are included in the search. By default, subfolders are included unless this option is unchecked. Matching items are then removed from the list. After deleting the items, the activity stores the IDs of the deleted items in the Deleted Item IDs workflow variable.
This custom SharePoint workflow activity efficiently deletes items from a list based on specified filter conditions, with optional parameters to refine the query to specific folders and subfolders. By capturing the deleted item IDs, this activity ensures transparency and tracking for subsequent workflow steps.
Activity for the current item:
The delete items activity can also be performed for the current item. To do this, on the activity form, select the checkbox next to the current item value. After checking the checkbox, the current list/library in the SharePoint list field will be automatically selected. The SharePoint list, Filter list items, Search in folder and Include subfolders fields will become uneditable.
The Deleted items IDs output parameter field will remain editable. For this activity, the current element will be removed.