Delete Items
Definition
The "Delete Items" action allows a user to permanently remove one or more specified items from a SharePoint list. By providing the site, the list, and the unique IDs of the items, this action facilitates the bulk deletion of records in a single, automated step.
Key capabilities include:
- Specifying the exact SharePoint site and list for the operation.
- Deleting multiple items at once by providing a comma-separated list of item IDs.
This action is essential for automating data lifecycle management, archiving old records, or cleaning up unnecessary data within SharePoint lists, thereby maintaining data integrity and relevance.
Inputs
- connection This field is used to establish an authorized connection to your SharePoint environment, allowing zenphi to interact with your sites and lists on your behalf.
- Site ID This is the unique identifier for the SharePoint site that contains the list from which you want to delete items. After establishing a connection, you can select the site from a drop-down menu or provide the ID dynamically.
- List ID This specifies the particular list within the selected site where the items are located. You can either enter a List ID directly or select one from the drop-down menu that populates after a site is chosen.
- Item IDs
This field requires the unique identifiers for the items you wish to delete from the specified list. You can select multiple items from a drop-down menu or enter their IDs as a comma-separated list (e.g.,
Item ID 1, Item ID 2
).
Outputs
- Site ID The unique identifier of the SharePoint site where the items were deleted.
- List ID The unique identifier of the SharePoint list from which the items were deleted.
- All Items Deleted
A boolean value that returns
true
if all specified items were successfully deleted. It returnsfalse
if the deletion failed for at least one of the items. - Selected Items This is a list containing the results for each item that was selected for deletion. Each object in the list includes the following properties:
- Item ID - The unique identifier of the item that was targeted for deletion.
- Is Deleted - A boolean value that is
true
if the specific item was deleted successfully andfalse
otherwise.
Example Use Cases
- Automate Record Archiving Periodically find and delete items that meet certain criteria, such as being older than a specified date, to keep lists clean and relevant.
- Clean Up Completed Tasks Automatically remove items from a task or request list once their status is changed to "Completed" or "Closed," ensuring the list only contains active items.
- Manage Data Lifecycle Fulfill data retention policies by automatically deleting records from a SharePoint list after a mandated period has passed.
- Process Data Removal Requests Trigger a workflow to delete specific user data from a list to comply with privacy regulations like GDPR, based on a user's request ID.
Example
Scenario: An IT department uses a SharePoint list to track support tickets. Once a ticket's status is updated to "Closed" and has remained closed for 30 days, it needs to be permanently deleted from the active list to comply with data retention policies and improve list performance. Manually tracking and deleting these old tickets is time-consuming and prone to error.
Steps to Implement:
- Create a scheduled zenphi Flow that runs daily.
- Use the SharePoint "Get Items" action to find all tickets that need to be deleted. Configure a filter query to find items where
Status
is equal to 'Closed' andModified
is less than or equal toaddDays(utcNow(), -30)
. - Add a "Data Operation - Select" action to extract only the
ID
from the list of items returned by the "Get Items" action. - Use a "Data Operation - Join" action to convert the array of IDs from the previous step into a single, comma-separated string.
- Configure the Delete Items action.
- Connection: Select your established SharePoint connection.
- Site ID: Choose the SharePoint site where the support ticket list is located.
- List ID: Select the "Support Tickets" list from the dropdown.
- Item IDs: Use the token picker to insert the comma-separated string of IDs generated by the "Data Operation - Join" action in the previous step.
Outcome: The workflow automatically purges closed support tickets after 30 days without any manual intervention. This ensures compliance with data retention policies, keeps the active ticket list clean and efficient, and frees up IT staff to focus on current support issues rather than manual data cleanup.
Best Practices
- Confirm Before Deletion Since deleting items is a permanent action, consider adding a confirmation or approval step in your workflow for critical data. This prevents accidental deletion of important records.
- Use Dynamic IDs Avoid hardcoding Item IDs. Instead, use a preceding action like "Get Items" with a filter to dynamically find the specific items you want to delete. This makes the workflow adaptable and reduces the risk of deleting the wrong items.
- Implement Error Handling
Use the
All Items Deleted
andSelected Items
outputs to verify that the deletion was successful. If an item fails to delete, you can build logic to send a notification or log the error for manual review. - Log Deletion Activities For auditing and compliance, add a step after the "Delete Items" action to log the details of the deleted items (e.g., their IDs, and the date of deletion) to a separate logging list or an external system.
Updated about 2 hours ago