> 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/flow/tutorials/components/navigation/building-a-navigation-menu-with-related-records.md).

# Building a Navigation Menu with Related Records

Turn an account's open opportunities into a side menu and show the details of the one the agent clicks next to it, on the same flow screen.

A service agent reviewing an account wants to scan its open opportunities and read one in detail without opening each record. A side menu that lists the opportunities by name, with their stage under each name, does that in one screen. When the agent clicks one, its details appear next to the menu.

<figure><img src="https://27923732-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1FUd4apB9YHgCEMUFbVb%2Fuploads%2FSNUtvcS6XKJICxUlWHkX%2Fbuilding-a-navigation-menu-with-related-records-result.png?alt=media" alt="A vertical menu of open opportunities with stages and the selected one&#x27;s details below"><figcaption><p>Each open opportunity is a menu item, its details show on click.</p></figcaption></figure>

## Before you start

* A screen flow that receives the account Id, for example a text input variable `recordId`.
* The [Navigation](https://docs.avonnicomponents.com/flow/flow-components/navigation.md) reference, for the other Data Mappings fields.

## Steps

{% stepper %}
{% step %}

### Get the account's opportunities

Add a **Get Records** element before the screen:

* **Object**: Opportunity
* **Filter**: `AccountId` **Equals** `{!recordId}`, and `IsClosed` **Equals** `False` for open opportunities only
* **Sort**: `CloseDate`, ascending
* **How Many Records to Store**: All records

Name it `Get_Opportunities`. Its record collection is the menu's data.
{% endstep %}

{% step %}

### Point the Navigation at the collection

1. Add a **Screen** element and drag an **Avonni Navigation** onto it. Name it `OppMenu`.
2. In the Component Builder, set **Orientation** to **Vertical**.
3. Choose the **Variable** data source and select **Get Opportunities** under **Items Collection**.

Each record in the collection becomes one menu item.
{% endstep %}

{% step %}

### Map the fields of each item

In **Data Mappings**, tell the Navigation which field fills each part of an item:

| Mapping         | Field                | What the agent sees             |
| --------------- | -------------------- | ------------------------------- |
| **Label**       | **Name**             | The opportunity name            |
| **Value**       | **Id** (the default) | Nothing: it identifies the item |
| **Description** | **Stage**            | The stage, under the name       |

Keep **Value** on the record Id. It is unique, which a name is not, and it is what the Navigation returns when the agent clicks. **Description** only shows in a vertical menu.

<figure><img src="https://27923732-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1FUd4apB9YHgCEMUFbVb%2Fuploads%2F8X48uvYZUvZFBgeMjZ8F%2Fbuilding-a-navigation-menu-with-related-records-mappings.png?alt=media" alt="Data Mappings mapping Name to Label, Id to Value and StageName to Description" width="320"><figcaption><p>Name, Id and stage fill each item.</p></figcaption></figure>
{% endstep %}

{% step %}

### Show the selected opportunity

1. Below the Navigation, add a **Section**, and inside it a **Display Text**.
2. In the Display Text, insert fields from `OppMenu` > **Active Navigation Item SObject**: for example `{!OppMenu.activeNavigationItemSObjectValue.Amount}` and `{!OppMenu.activeNavigationItemSObjectValue.CloseDate}`.
3. On the section, open **Set Component Visibility**: `OppMenu` > **Active Navigation Item Value** **Is Null** `False`.

**Active Navigation Item SObject** is the whole record behind the clicked item, so any field queried by `Get_Opportunities` is available without a second Get Records. The visibility rule hides the empty section until the agent picks an opportunity.
{% endstep %}

{% step %}

### Save and test

Save and click **Debug** with an account that has open opportunities. The menu lists them by name, each with its stage below. No item is highlighted and the details section is hidden. Click an opportunity: it becomes the highlighted item and its amount and close date appear below the menu.
{% endstep %}
{% endstepper %}

To act on the clicked record after the screen, for example in an **Update Records** element, read the same **Active Navigation Item SObject** output. To open a screen per opportunity instead, add a **Select** interaction as in [Reuse one menu across a multi-screen flow](https://docs.avonnicomponents.com/flow/tutorials/components/navigation/reuse-one-menu-across-a-multi-screen-flow.md).

## Troubleshooting

<details>

<summary>The menu is empty</summary>

Run the flow in **Debug** and check that `Get_Opportunities` returned records for that account. Then check that **Get Opportunities** is selected under **Items Collection** and that **Label** is mapped: an item with no label shows nothing.

</details>

<details>

<summary>A field in the details section is blank</summary>

**Active Navigation Item SObject** only carries the fields the Get Records element stored. If you chose specific fields, add the ones the Display Text reads.

</details>

<details>

<summary>The stage does not show under the name</summary>

**Description** only renders in a vertical menu. Set **Orientation** to **Vertical**.

</details>

## Related tutorials

* [Build tabs on one screen with Navigation](https://docs.avonnicomponents.com/flow/tutorials/components/navigation/build-tabs-on-one-screen-with-navigation.md): fixed tabs instead of records, with the same visibility technique.
* [Add sub-menus and columns to a navigation menu](https://docs.avonnicomponents.com/flow/tutorials/components/navigation/add-sub-menus-and-columns-to-a-navigation-menu.md): nest items under a parent item.
* [Build a navigation menu from a picklist](https://docs.avonnicomponents.com/flow/tutorials/components/navigation/build-a-navigation-menu-from-a-picklist.md): items from a field's values rather than from records.


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.avonnicomponents.com/flow/tutorials/components/navigation/building-a-navigation-menu-with-related-records.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
