Delete records
Table of Contents
Note: This task is applicable only to Zoho Creator.
Overview
The delete record deluge task deletes a form's records which meet a given criteria.
The criteria is mandatory.
How to perform batch deletes
Set up a scheduled workflow that runs at regular intervals (for example, every 30 seconds or 1 minute). Each run deletes a fixed batch of records (such as 50,000) and automatically stops once there are no records left to delete.
Syntax
delete from <form_link_name> [<criteria>];
| Parameter | Description | |
|---|---|---|
| <form_link_name> | Link name of the form from which the records will be deleted. | |
| <criteria> | Criteria based on which the records will be deleted. | |
Things to keep in mind
- Deleting a child form's record added as a subform entry from a parent form, will empty that subform entry in the parent form as well, even if the subform field is marked as mandatory.
- Deleting a parent form record only delinks the subform fields connected to the parent form record. In order to delete all the linked subform records when a parent form record is deleted, use Delete records task on Delete on validation workflow of the parent form. (Refer Example 4)
- Deleting a record in a lookup form will empty the corresponding lookup field's value in the related form, even if the lookup field is marked as mandatory.
If you wish to delete all records in the specified form, use the following script as criteria:
[ID != 0]
It is advisable to fetch all records only when absolutely needed. Fetching all records generates a load resulting in performance issues.
This task can be used in the following events
| When a record is Created | ||
| On Load | Yes | |
| On Validate | Yes | |
| On Success | Yes | |
| On User input | Yes | |
| Subform on add row | Yes | |
| Subform on delete row | Yes | |
| When a record is Created or Edited | ||
| On Load | Yes | |
| On Validate | Yes | |
| On Success | Yes | |
| On User input | Yes | |
| Subform on add row | Yes | |
| Subform on delete row | Yes | |
| When a record is Edited | ||
| On Load | Yes | |
| On Validate | Yes | |
| On Success | Yes | |
| On User input | Yes | |
| Subform on add row | Yes | |
| Subform on delete row | Yes | |
| When a record is Deleted | ||
| On Validate | Yes | |
| On Success | Yes | |
| Other workflow events | ||
| On a scheduled date | Yes | |
| During approval process | Yes | |
| During payment process | Yes | |
| In a Custom Function | Yes | |
| In an Action item in report | Yes | |
Examples
The following script deletes all records with "Status" field value as "Resigned".
delete from Employees[Status == "Resigned"];
The following script deletes all records of members who are above 65 years of age.
delete from Employee[DOB <= zoho.currentDate.subYear(65)]; //subYear is a which subtracts given number of years, which in this case is 65. //zoho.currentDate is a which holds current(today) date value.
The following script deletes all records which have null value for "Name" field.
delete from Employee[Name == null];
The following script deletes all suform records linked to the current parent form record.
Note: Write this script in On Delete On Validate workflow event of parent form to delete all the linked subform records whenever a parent form record is deleted.subforms_ids = parentForm_linkname[ID == input.ID].subForm_fieldname; for each sub in subforms_ids { delete from subForm_linkname[ID == sub]; }