# Delete a Record

The "Delete a Record" action permanently removes a record from your data source. This action can delete either the current record the button is on, or a related record connected through a single-linked relationship field.

{% hint style="danger" %}
**Warning:** Deleting a record is permanent and cannot be undone. Always use appropriate confirmation modals and visibility rules to prevent accidental deletions.
{% endhint %}

## When to Use Delete a Record

Use the Delete a Record action when you need to:

* **Remove completed or obsolete records**: Delete finished tasks, expired promotions, or outdated entries
* **Clean up test data**: Remove sample or test records during development
* **Implement user-requested deletions**: Allow users to delete their own content or submissions
* **Enforce data retention policies**: Remove records that have passed retention periods
* **Cascade deletions**: Delete a main record and related records in sequence

## Setting Up a Delete a Record Action

### Step 1: Create the Action Button

1. In build mode, navigate to the record page where you want the delete button
2. Click the "+" button in the Action Buttons section
3. Click the edit icon to configure the button

### Step 2: Configure Button Appearance

* **Button Text**: Clear label indicating deletion (e.g., "Delete", "Remove", "Delete Task")
* **Appearance**: Use **Danger** (red) to indicate destructive action
* **Icon**: Trash can or X icon to reinforce the action
* **Button Tooltip**: Explain what will be deleted

### Step 3: Configure the Action Type

Always use **Modal** type for delete actions to prevent accidental clicks:

* **Type**: Select **Modal** (not "One click")
* **Modal Title**: Clear title like "Delete \[Record Name]?" or "Confirm Deletion"
* **Modal Description**: Explain what will be deleted and that it's permanent
* **Confirm Button Text**: Use explicit text like "Delete Permanently", "Yes, Delete", or "Confirm Deletion"

### Step 4: Select What to Delete

Choose which record to delete:

**Option 1: This Record**

* Deletes the current record the button is on
* Use when the button is on the record you want to delete

**Option 2: Related Record**

* Select a single-linked relationship field (e.g., "User → Client")
* Deletes the related record, not the current one
* Use when you want to delete a connected record

### Step 5: Configure Notification

* **Notification**: Turn **On**
* **Notification Type**: Choose **Success** (green) or **Information** (blue)
* **Notification Text**: Confirm the deletion (e.g., "Task deleted successfully")

## Common Use Cases

### 1. Delete Current Task/Item

**Scenario**: Allow users to delete their own tasks

**Button Configuration:**

* Button Text: "Delete Task"
* Appearance: Danger (red)
* Icon: Trash icon
* Type: Modal
* Modal Title: "Delete this task?"
* Modal Description: "This will permanently delete this task. This action cannot be undone."
* Confirm Button Text: "Delete Permanently"

**Action Configuration:**

* What Should Happen: Delete a record
* Which Record: This record
* Notification: "Task deleted successfully"

**Visibility Rules:**

* Only show if: `Assigned To equals Logged in User` (users can only delete their own tasks)

***

### 2. Delete Related Record

**Scenario**: Delete a client account from a project record

**Button Configuration:**

* Button Text: "Remove Client"
* Appearance: Danger
* Icon: User X icon
* Modal Title: "Remove Client from Project?"
* Modal Description: "This will delete the client record entirely, not just unlink them from this project."

**Action Configuration:**

* Which Record: This record → Client (single-linked field)
* Notification: "Client removed successfully"

**Visibility Rules:**

* Only show to: Admin, Project Manager roles

***

### 3. Multi-Step Cleanup

**Scenario**: Archive data before deleting, or delete related records first

**Step 1 - Update Record:**

* Update Status to "Archived"

**Step 2 - Show Message:**

* "Data has been archived. Ready to delete?"

**Step 3 - Delete Record:**

* Delete This Record

***

### 4. Conditional Delete with Confirmation

**Scenario**: Only allow deletion if certain conditions are met

**Button Configuration:**

* Button Text: "Delete Order"
* Appearance: Danger
* Modal Title: "Delete Order #{{record.order\_number}}?"
* Modal Description:

```markdown
## You are about to delete:
- Order: {{record.order_number}}
- Customer: {{record.customer.name}}
- Total: ${{record.total}}

This will permanently remove all order data and cannot be recovered.
```

**Visibility Rules:**

* Show only if: `Status equals "Cancelled"` AND `Payment Status equals "Refunded"`
* User Role: Admin only

***

### 5. Bulk Delete Option

**Scenario**: Delete multiple records at once using bulk actions

See the [Bulk Actions](/actions/action-buttons/bulk-actions.md) guide for details on deleting multiple records simultaneously.

***

### 6. Delete with Workflow Trigger

**Scenario**: Trigger cleanup workflows before deletion

**Step 1 - Run Workflow:**

* Run workflow: "Cleanup Related Data"
* Wait for completion

**Step 2 - Delete Record:**

* Delete This Record

**Use Case**: Send notifications, archive data elsewhere, or clean up related records before deletion.

***

### 7. Self-Service Account Deletion

**Scenario**: Allow users to delete their own accounts

**Button Configuration:**

* Button Text: "Delete My Account"
* Appearance: Danger
* Modal Title: "⚠️ Delete Your Account?"
* Modal Description:

```markdown
## This will permanently delete:
- Your profile and account data
- All your submissions and content
- Your activity history

## What happens next:
1. All your data will be deleted immediately
2. You will be logged out
3. This action cannot be reversed

Please export your data before deleting if you need a copy.
```

* Confirm Button Text: "Yes, Delete My Account"

**Action Configuration:**

* Which Record: This record → User
* Notification: "Your account has been deleted. Thank you for using our service."

**Visibility Rules:**

* User must be viewing their own profile: `This Record equals Logged in User`

## Important Considerations

### Preventing Accidental Deletions

1. **Always Use Modal Type**
   * Never use "One click" for delete actions
   * Always require explicit confirmation
2. **Clear Modal Descriptions**
   * Explain exactly what will be deleted
   * Mention that the action is permanent
   * Show key details of what's being deleted (names, IDs, etc.)
3. **Use Danger Appearance**
   * Red color signals destructive action
   * Helps users recognize the seriousness
4. **Explicit Confirm Button Text**
   * Avoid generic "OK" or "Confirm"
   * Use "Delete Permanently", "Yes, Delete", or "Delete \[Item Name]"

### Permissions and Visibility

**Set appropriate visibility rules:**

* Restrict to specific roles (e.g., Admins only)
* Only show on user's own records
* Hide when deletion shouldn't be allowed (e.g., `Status not equals "Draft"`)

**Remember**: Visibility rules don't enforce security—always set proper table permissions too.

### Data Integrity

**Consider relationships:**

* What happens to related records?
* Are there required relationships that will break?
* Should you delete or unlink related records first?

**Use workflows for cleanup:**

* Send notifications before deletion
* Archive data to another system
* Update related records
* Log deletion for audit purposes

## Cascading Deletes

To delete multiple related records, chain delete actions:

**Example**: Delete a project and all its tasks

**Step 1**: Delete all related tasks

* Which Record: This record → Tasks (would need to use bulk delete or workflow)

**Step 2**: Delete the project

* Which Record: This record

**Note**: Consider using an on-demand workflow for complex cascading deletions.

## Best Practices

### Do:

* ✅ Always use Modal type for confirmations
* ✅ Use Danger (red) appearance
* ✅ Write clear, explicit modal descriptions
* ✅ Set strict visibility rules
* ✅ Show success notifications
* ✅ Use dynamic field values in messages ({{record.name}})
* ✅ Test thoroughly before deploying
* ✅ Consider archiving instead of deleting

### Don't:

* ❌ Use "One click" type for delete actions
* ❌ Use vague button text like "Remove" or "Clear"
* ❌ Allow deletion of records with active dependencies
* ❌ Forget to set proper permissions
* ❌ Delete without user confirmation
* ❌ Use generic "OK" for confirmation buttons
* ❌ Show delete buttons to unauthorized users

## Alternatives to Deletion

Consider these alternatives before implementing permanent deletion:

### 1. Soft Delete (Archive)

Instead of deleting, update a field:

* Add a boolean field "Is Archived"
* Update record to set "Is Archived = true"
* Filter views to hide archived records

**Benefits:**

* Data can be recovered
* Maintains audit history
* Safer for important records

### 2. Move to Trash

* Create a "Status" field with "Deleted" option
* Update Status to "Deleted" instead of deleting
* Create a "Trash" view showing deleted items
* Permanently delete only after retention period

### 3. Transfer Ownership

Instead of deleting, reassign:

* Update "Owner" field to another user
* Move record to different category
* Reassign to admin for review

## Troubleshooting

### Button Doesn't Appear

* Check visibility rules match current user/record state
* Verify user has permission to view the button
* Ensure button isn't hidden in settings

### Delete Action Fails

* **Permission error**: User lacks delete permission on the table
* **Relationship constraints**: Related records prevent deletion
* **Required relationships**: Can't delete if other records depend on it
* **Data source rules**: External database may have constraints

### Related Records Aren't Deleted

* Delete actions only delete the specified record
* Use workflows or multiple delete actions for cascading
* Check your data source's cascade delete settings

### Confirmation Modal Doesn't Show

* Ensure Type is set to "Modal" not "One click"
* Check that modal title and description are configured
* Try refreshing the page or republishing

### Deleted Record Still Shows

* Refresh the view or page
* Check if you're viewing cached data
* Verify the deletion actually completed (check data source)

## Security Considerations

### Table Permissions

Set appropriate delete permissions at the table level:

* Admin role: Can delete any record
* Manager role: Can delete records in their department
* User role: Can delete only their own records
* Read-only role: Cannot delete any records

### Audit Logging

Consider implementing audit logs:

* Use workflows to log deletions before they occur
* Record: who deleted, what was deleted, when
* Store in a separate audit table

### Compliance

For regulated industries:

* Implement retention policies
* Ensure deletion complies with GDPR, CCPA, etc.
* Provide data export before deletion
* Log all deletions for compliance audits

## Advanced: Delete with Confirmation Checkbox

For critical deletions, add an update action first:

**Step 1 - Update Record:**

* Show field: "Confirm Deletion" (boolean)
* User must check box to confirm

**Step 2 - Delete Record:**

* Only proceeds if checkbox was checked
* Delete This Record

**Visibility for Step 2:**

* Only show if: `Confirm Deletion equals true`


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://guides.noloco.io/actions/action-buttons/delete-a-record.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
