> 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/tree-grid/browse-accounts-contacts-and-cases.md).

# Browse accounts, contacts and cases

Open each subsidiary onto its contacts and each contact onto their open cases, in one screen flow Tree Grid on the Account page, with three linked queries.

Before a quarterly review with Meridian US Logistics, an account manager wants to see each of its hubs, who the contacts are there, and which of those contacts have open cases. With the [Tree Grid](https://docs.avonnicomponents.com/flow/flow-components/tree-grid.md) in **Multi-Level** mode, one screen flow on the Account page answers it: hubs at the top, contacts under each hub, open cases under each contact.

<figure><img src="https://27923732-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1FUd4apB9YHgCEMUFbVb%2Fuploads%2Fxgbh15fUl4RaaOzMqZjy%2Ftree-grid-browse-accounts-contacts-and-cases-result.png?alt=media" alt="A Tree Grid in a screen flow listing three hubs of Meridian US Logistics, one opened onto its contacts and one contact opened onto two open cases with status and priority"><figcaption><p>Hubs, then their contacts, then each contact's open cases, from three linked queries.</p></figcaption></figure>

## Before you start

* Your screen flow has a `recordId` input variable (Text, available for input) and runs on the Account record page with **Pass record ID into this variable** checked. If not, follow [How to pass your current RecordID in your screen flow](https://docs.avonnicomponents.com/flow/tutorials/tips-and-tricks/how-to-pass-your-current-recordid-in-your-screen-flow.md).
* The account has subsidiaries (accounts whose **Parent Account** points at it), and they have contacts and cases.
* If what you need is the account's own parents and subsidiaries, with no other object, [Show an account hierarchy](https://docs.avonnicomponents.com/flow/tutorials/components/tree-grid/show-an-account-hierarchy.md) is simpler.

## Steps

{% stepper %}
{% step %}

### Add the Tree Grid to a screen

1. In Flow Builder, add a Screen element and drag the Avonni **Tree Grid** onto it.
2. Select it and click **Open Component Builder**.
3. In the **Header** group, set **Title** to `Hubs, contacts and open cases`.
   {% endstep %}

{% step %}

### Query the subsidiaries for the top level

1. Open the **Data Source** section of the **Properties** tab, just above **Data Mappings**, and choose **Query**.
2. Set **Object API Name** to `Account`.
3. Under **Filters**, click **Add Condition**: **Parent Account ID** Equals your flow's `recordId` resource.
4. Under **Order By**, add **Account Name**, ascending.

Opened from Meridian US Logistics, this level returns its three hubs.
{% endstep %}

{% step %}

### Add the contacts under each account

1. In the query editor, leave **Mode** on **Multi-Level**.
2. Under **Child Items**, click **Add Item**.
3. Set **Child Object API Name** to `Contact` and **Relationship Field** to **Account ID**.
4. Under **Order By**, add **Last Name**, ascending.

The **Relationship Field** is the lookup on the child that points at the level above. Here, each Contact's **Account ID** points at its hub.
{% endstep %}

{% step %}

### Add the open cases under each contact

1. Open the menu of the `Contact` entry and choose **Add**. The new entry is created under it, one level deeper.
2. Set **Child Object API Name** to `Case` and **Relationship Field** to **Contact ID**.
3. Under **Filters**, click **Add Condition**: **Closed** Equals `false`.

Choose **Contact ID**, not **Account ID**: the level above is now a contact.

<figure><img src="https://27923732-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1FUd4apB9YHgCEMUFbVb%2Fuploads%2Fcha8QVLy6ultZ8hYpfPN%2Ftree-grid-browse-accounts-contacts-and-cases-child-items.png?alt=media" alt="The Child Items list of the Tree Grid query editor with Case nested under Contact, and the Case entry open on Relationship Field Contact ID and a Closed equals False filter" width="320"><figcaption><p>Case sits under Contact and ties to it with Contact ID.</p></figcaption></figure>
{% endstep %}

{% step %}

### Choose the columns

Under **Data Mappings**, add these columns, in this order:

| Object API Name | Source Field   | Type     |
| --------------- | -------------- | -------- |
| Account         | Account Name   | Text     |
| Account         | Annual Revenue | Currency |
| Contact         | Title          | Text     |
| Contact         | Email          | Email    |
| Case            | Status         | Badge    |
| Case            | Priority       | Text     |

Each column reads one object, so it stays empty on the rows of the other two. The first column is the exception: because it reads the account's name field, every row shows its own name there. Hubs show their account name, contacts their full name, cases their case number.

Turn on **Custom Label** on the first column and set **Label** to `Name`, since it no longer holds only accounts.
{% endstep %}

{% step %}

### Save and test

1. Save and activate the flow.
2. Open Meridian US Logistics and run the flow from its page.

You see three rows: Meridian Atlanta Hub, Meridian Chicago Hub and Meridian Dallas Hub, with their annual revenue. Open Meridian Chicago Hub: its contacts appear with their title and email. Open a contact: their open cases appear with status and priority. A contact with no case at all has no toggle.
{% endstep %}
{% endstepper %}

{% hint style="info" %}
To list an account's cases directly under it, beside its contacts, add the `Case` entry under **Child Items** with **Add Item** (not from the contact's menu) and **Account ID** as its **Relationship Field**. Each hub then opens onto two rows, Contacts and Cases, and the records sit under them. Turn on **Show Number of Children** in the **Properties** tab to print each row's count beside its label.
{% endhint %}

## Troubleshooting

<details>

<summary>"Please select an object and a relationship field for each query."</summary>

One entry under **Child Items** is missing its **Child Object API Name** or its **Relationship Field**. Open each entry and fill both.

</details>

<details>

<summary>The grid is empty</summary>

The top level found no account. Check that the flow receives `recordId` (see [Test a screen flow that needs a record Id](https://docs.avonnicomponents.com/flow/tutorials/tips-and-tricks/test-a-screen-flow-that-needs-a-record-id.md)), and that the condition reads **Parent Account ID**, not **Account ID**: an account with no subsidiary returns nothing at this level.

</details>

<details>

<summary>Contacts open, but no contact has a toggle</summary>

The `Case` entry ties to the wrong field. Under a contact, the **Relationship Field** must be **Contact ID**. Also check that the entry sits under `Contact` and not beside it.

</details>

<details>

<summary>Case is not in the child object list</summary>

The list starts with the objects related to the level above. Turn on **All Objects** next to **Child Object API Name** to search every object.

</details>

<details>

<summary>Columns are blank on some rows</summary>

Expected: an Account column has nothing to show on a Contact or Case row. Keep the first column on the name field so every row still has a label.

</details>

## Related tutorials

* [Show an account hierarchy](https://docs.avonnicomponents.com/flow/tutorials/components/tree-grid/show-an-account-hierarchy.md): the whole customer group, parents included, from one object.
* [Work with selected rows](https://docs.avonnicomponents.com/flow/tutorials/components/tree-grid/work-with-selected-rows.md): let the user tick cases and close them after the screen.
* [Add row and header actions](https://docs.avonnicomponents.com/flow/tutorials/components/tree-grid/add-row-and-header-actions.md): open a contact or a case from its row.


---

# 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/tree-grid/browse-accounts-contacts-and-cases.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.
