# Delete Record

## 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).

***

## Configuring the Delete Record Interaction

To perform a delete operation, you must specify which Record Variable represents the data you want to remove.

### 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}`).

***

## Important Requirement: The Record ID

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.

***

## Best Practice: User Confirmation

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.

***

## Navigation After Delete

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/navigation-and-notifications/navigate.md): (To Opportunity List View)


---

# 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://docs.avonnicomponents.com/dynamic-components/component-builder/interactions/variable-operations/delete-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.
