Delete Records
Definition
The Delete Records action enables you to permanently remove multiple records from a specific zenphi Table based on conditions you define. It is a powerful tool for managing data hygiene by programmatically clearing out old, irrelevant, or completed entries that match your specified criteria.
Key capabilities include:
- Targeting a specific zenphi Table for record deletion.
- Building precise deletion rules using one or more conditions with logical operators.
- Performing bulk deletions to efficiently clean up large datasets.
This action is fundamental for automating data lifecycle management, ensuring your tables remain optimized, up-to-date, and contain only relevant information.
Inputs
-
Table
- Purpose: This field is for selecting the specific zenphi Table from which you want to delete records.
- Practical Guidance: You will typically choose the table from a dropdown menu that lists all available tables in your zenphi environment. This is usually a static value set when you design the automation, as the target table rarely changes during a flow's execution.
- Use Case Context: You would use the 'Table' field to tell zenphi you want to remove entries from your "Archived Tasks" table.
-
Condition
- Purpose: This field allows you to define the specific rules that identify which records to delete. Setting a condition is crucial to ensure you only remove the intended records and avoid accidental data loss.
- Practical Guidance: You build a filter by specifying a column, an operator, and a value. You can add multiple conditions and link them with 'and' or 'or' logic to create highly specific filters.
- Use Case Context: You would use the 'Condition' field to create a rule to "delete all records where the 'Status' column is equal to 'Completed'."
- column
- Purpose: To choose the column within your selected table that you want to evaluate.
- Practical Guidance: After selecting a table, this field will present a dropdown list of all its columns for you to choose from.
- Use Case Context: You would select the "Created Date" column to filter records based on when they were added.
- operator
- Purpose: To define the comparison you want to perform on the selected column.
- Practical Guidance: You will select a logical operator from a predefined list, such as
equal to,not equal to,contains,is null, orstarts with. - Use Case Context: You would choose the "is less than" operator to find all records created before a specific date.
- value
- Purpose: To provide the data that the column's content will be compared against.
- Practical Guidance: You can provide this as a static value by typing it directly (e.g., the text "Archived"). Alternatively, you can use a dynamic value from the token picker, such as using the output from a "Get Current Date" action to delete all records older than today.
- Use Case Context: You would enter the static value "High" to find all records where the 'Priority' column is set to High.
Outputs
- Deleted Records
- Data Description: This output provides a single number representing the total count of records that were successfully deleted from the table during the action's execution.
- Workflow Utility: This count is extremely useful for logging and creating conditional logic in your flow. For example, you can pass this number to a "Log Message" action to create an audit trail like "Successfully deleted 15 archived records." You could also use it in a condition: if 'Deleted Records' is greater than 0, send a success notification email; otherwise, do nothing.
Example Use Cases
- Clear Completed Tasks Automatically delete records from a project management table where the 'Status' column is marked as 'Completed' to keep the active task list clean.
- Enforce Data Retention Policies Periodically run a flow to delete records older than a specified date, ensuring compliance with data privacy regulations like GDPR.
- Remove Processed Staging Data After data is successfully transferred from a temporary staging table to a permanent one, delete the original records to free up space and prevent reprocessing.
- Manage Inventory Levels Delete records for discontinued products or items with zero stock from an inventory table to ensure data accuracy.
Example
Scenario: A project management team uses a zenphi Table named "Project Tasks" to track all their work. The table has become cluttered with tasks that were completed months ago, making it difficult to navigate and slowing down performance. The team wants to automate a weekly cleanup process to delete any tasks that have been marked as 'Completed' for more than 30 days.
Steps to Implement:
- Create a new flow and add a Scheduled Flow trigger. Configure it to run weekly, for instance, every Sunday at 2 AM.
- Add a Date Calculator action to determine the cutoff date. Configure it to subtract 30 days from the current date. This will be used in the condition.
- Add and configure the Delete Records action with the following settings:
- Table: Select the "Project Tasks" table from the dropdown list.
- Condition: Add the first rule to target completed tasks.
- column: Select the "Status" column.
- operator: Choose
equal to. - value: Type the static value
Completed. - Condition: Add a second rule using the
andoperator to target older tasks. - column: Select the "Completion Date" column.
- operator: Choose
is less than. - value: Use the token picker to select the calculated date output from the "Date Calculator" action in step 2.
- (Optional) Add a Log Message action after the deletion. Configure it to log the
Deleted Recordsoutput token to create an audit trail, for example: "Weekly Cleanup: Deleted [Deleted Records] completed tasks."
Outcome: The workflow automatically runs every week, identifies, and permanently deletes all tasks that were completed over 30 days ago. This eliminates the need for manual cleanup, ensures the "Project Tasks" table remains lean and performant, and helps the team focus only on active and relevant tasks.
Best Practices
- Test Conditions First Before implementing a
Delete Recordsaction in a production flow, use the exact same conditions in aGet Recordsaction and log the output. This allows you to verify which records will be targeted for deletion without any risk of accidental data loss. - Use Specific Conditions Avoid overly broad conditions. Whenever possible, use multiple conditions linked with
andlogic to precisely target the records you intend to delete. For example, instead of just deleting based on a date, add a condition for the record's status (e.g., 'Status' is 'Archived' AND 'Modified Date' is less than 90 days ago). - Log the Outcome Always use the
Deleted Recordsoutput count in a subsequent logging or notification action. This creates a valuable audit trail, making it easy to confirm how many records were deleted during each run and to troubleshoot any unexpected behavior. - Schedule During Off-Peak Hours For flows that may delete a large number of records from a critical table, schedule the automation to run during low-traffic periods (e.g., overnight or on weekends). This minimizes any potential performance impact on users who may be interacting with the table.
Updated about 7 hours ago
