> 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/get-record.md).

# Get Record

The Get Record interaction retrieves a Salesforce record and stores it into a record variable in your Dynamic Component.

## Overview

The Get Record interaction fetches a single Salesforce record by its Id and stores it in a record variable in your Dynamic Component. This is the primary method for populating your component with a specific record that is not automatically available from the page context.

You can use this interaction to:

* Retrieve details of a related record (e.g., getting the Parent Account details while on a Contact page).
* Fetch a specific record based on a user's selection or input.
* Refresh data after a record is updated to keep the UI up to date.

***

## Configuration

The interaction has two parts: choosing the record variable that will store the result, and supplying the Id of the record to fetch.

#### 1. Choose the Record Variable

Before configuring the interaction, you need a "container" to hold the record you retrieve.

* **Open the Variables panel** (Database icon).
* **Create a New Variable** (or select an existing one).
* **Data Type**: Select `Record` (since you are fetching a single record).
* **Object**: Select the object of the record you are fetching (e.g., `Account`).
* **API Name**: Give it a clear name (e.g., `parentAccountData`).

Back in the interaction, set the **Record Variable** to this variable — it is where the retrieved record is stored.

#### 2. Supply the Record Id

* **Add the interaction** (e.g., to an On Load event or a Button On Click).
* **Action Type**: Select `Get Record`.
* **Record Id**: Provide the Id of the record to fetch. You can either:
  * Enter or map a specific Id (e.g., `{!$Component.record.AccountId}` — the Account Id from the current page), or
  * Reference the current page record so the interaction fetches the record the component is placed on.

***

## Example

### Scenario A: Fetching Related Data on Page Load

Goal: Display the "Parent Account's Industry" on a Case record page.

1. **Event**: Select the component's On Load interaction.
2. **Action**: Get Record.
3. **Record Id**: `{!$Component.record.AccountId}` (the Account Id from the current Case).
4. **Record Variable**: Store in `{!parentAccountVar}`.
5. **UI**: Bind a Text Block or Input to `{!parentAccountVar.Industry}`.

### Scenario B: Refetching Data After an Update

Goal: Refresh the component immediately after a user saves changes, ensuring they see the latest server-side values.

1. **Event**: On the "Save" button, create a chain of actions.
2. **Action 1**: Update Record (commits the changes).
3. **Action 2**: Get Record.
   * Fetch the same record by its Id.
   * Store the result in the *same* record variable.
   * *Result:* The UI updates instantly because the variable driving it has been refreshed.

***

## Important Considerations

**Fetching by Id**: This interaction fetches a single record by its Id. Make sure the Record Id you supply resolves to a valid record — an incorrect or empty Id returns no record.

**Handling Empty Results**: If no record matches the supplied Id, the record variable will remain null. You can handle this gracefully by adding a Condition interaction after the Get Record action:

* *If `{!myVariable.Id}` is empty:* Show a "No record found" message or hide the section.

**Field Accessibility:** The interaction respects Salesforce security. You can only retrieve fields that the current user has permission to view in Salesforce.


---

# 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/get-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.
