> For the complete documentation index, see [llms.txt](https://docs.avonnicomponents.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.avonnicomponents.com/dynamic-components/component-builder/interactions/delete-record.md).

# Delete Record

The Delete Record interaction permanently removes a Salesforce record directly from your Dynamic Component.

## Overview

The Delete Record interaction allows you to permanently remove a Salesforce record directly from your Dynamic Component. This interaction requires a Record ID to identify exactly which record to delete.

This action is irreversible within the component (though the record may go to the Salesforce Recycle Bin depending on your org's settings).

***

## Configuration

To perform a delete operation, you must specify which record you want to remove. You can identify it from a Record Variable, from the record currently displayed on the page, or by entering a record ID manually.

### Method 1: Deleting the Current Page Record

Use this method when your component is placed on a Record Page (e.g., an Opportunity Page) and you want to provide a button to delete the record currently being viewed.

1\. Define the Context

* Open your Dynamic Component's Settings (gear icon ⚙️).
* Set the [**Target Page Object**](/dynamic-components/core-concepts/target-page-object.md) to the object you are working on.
* *Result:* The `$Component.record` variable is now active and holds the ID of the current record.

2\. Configure the Interaction

* Add a Button component (e.g., label it "Delete").
* Add an On Click interaction.
* Action Type: Select `Delete Record`.
* Record Variable: Select Target Page Record.

### Method 2: Deleting a Specific Record Variable

Use this method when you want to delete a record that is *not* the main record of the page (e.g., deleting a specific row from a list of related contacts, or a record fetched via a "Get Records" action).

1\. Identify the Variable Ensure you have a Record Variable (e.g., `selectedContact`) that is currently populated with data. This is often done by:

* Using an [**On Load**](/dynamic-components/component-builder/on-load-interaction.md) > Get Records interaction.
* Using an Iterator or Collection where the user selects a specific item.

2\. Configure the Interaction

* Add the interactive component (e.g., a "Trash" icon button inside a list or card).
* Add an On Click interaction.
* Action Type: Select `Delete Record`.
* Record Variable: Select the specific variable you want to delete (e.g., `{!selectedContact}`).

### Method 3: Entering a Record ID Manually

Use this method when the record ID comes from elsewhere — a formula, a component attribute, or a static value.

* Add an On Click interaction.
* Action Type: Select `Delete Record`.
* Record Variable: Select Enter record ID manually.
* Record ID: Provide the Salesforce record ID to delete.

### The Record ID Requirement

For the delete action to work, the variable you select must contain the Salesforce Record ID.

* **Context Record**: The system automatically includes the ID.
* **Custom Variable**: If you populated the variable using a query (Get Records) or a Flow, you must ensure the Id field was included in the retrieved data.

### On Success and On Error

The Delete Record interaction lets you chain follow-up interactions for each outcome. Accepted follow-ups for both On Success and On Error are [Show Toast](/dynamic-components/component-builder/interactions/show-toast.md), Refresh All Queries, Refresh Query, [Get Record](/dynamic-components/component-builder/interactions/get-record.md), and [Assignment](/dynamic-components/component-builder/interactions/assignment.md).

***

## Example

If you delete the Current Page Record (Method 1), the user will be left on a page that no longer exists. You should chain a Navigate interaction immediately after the delete action to redirect the user elsewhere (e.g., back to the Object Home page or a parent record).

Example Chain:

1. Delete Record: (Target Page Record)
2. [Navigate](/dynamic-components/component-builder/interactions/navigate.md): (To Opportunity List View)

***

## Important Considerations

Because deleting data is a destructive action, it is highly recommended to ask for user confirmation before triggering the delete.

Recommended Flow:

1. Button Click: Triggers an Open Modal (or Open Alert) interaction asking "Are you sure?".
2. Modal "Confirm" Button: Triggers the Delete Record interaction.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.avonnicomponents.com/dynamic-components/component-builder/interactions/delete-record.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
