> 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/record-grid/compare-records-side-by-side-with-record-grid.md).

# Compare Records Side by Side with Record Grid

Put an account's open opportunities side by side in a screen flow, one column per deal, so a manager can compare amounts, stages and dates at a glance.

A rep asks for a discount on one of an account's deals. Before approving, the sales manager wants that account's three open opportunities next to each other: amount, close date, stage, probability. A Record Grid turns each opportunity into a column and each field into a row, so the manager reads the same figure for every deal along one line.

<figure><img src="https://27923732-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1FUd4apB9YHgCEMUFbVb%2Fuploads%2FQhLu7VuycOYY0QJuSt9g%2Frecord-grid-compare-records-side-by-side-with-record-grid-result.png?alt=media" alt="Record Grid titled Open deals with three opportunities as columns and Amount, Close Date, Stage, Win chance, Opportunity Type and Lead Source as rows"><figcaption><p>Three open deals of one account, compared field by field.</p></figcaption></figure>

## Before you start

* A screen flow that receives the account Id in a text variable named `recordId`, available for input. [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) shows how to launch it from the Account page.
* The Record Grid settings are described in the [Record Grid](https://docs.avonnicomponents.com/flow/flow-components/record-grid.md) reference.

## Steps

{% stepper %}
{% step %}

### Get the opportunities to compare

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

1. **Object**: Opportunity.
2. Filter: **AccountId** Equals `{!recordId}`, and **IsClosed** Equals `{!$GlobalConstant.False}`.
3. **Sort Order**: Ascending by **CloseDate**. The grid shows the records in this order, left to right.
4. **How Many Records to Store**: All records.
5. **How to Store Record Data**: Automatically store all fields.

The grid runs no query of its own, so the manager sees exactly what this element returns.
{% endstep %}

{% step %}

### Bind the grid to the collection

1. Add an Avonni **Record Grid** to the screen, give it the API name `Deal_Grid`, and select it. The **Edit Record Grid Component** panel opens.
2. At the bottom of the **Properties** tab, set **Data Source** to **Variable**. A new grid starts in **Manual**.
3. In **Records Collection**, pick the output of the Get Records element.
   {% endstep %}

{% step %}

### Head each column with the deal name

In **Data Mappings**, set **Column Header Field** to **Name**. Each column now opens with the deal's name.
{% endstep %}

{% step %}

### Add one row per field to compare

Under **Row Fields**, click **Add Row Fields** for each field, in the order the manager reads them: **Amount**, **Close Date**, **Stage**, **Probability (%)**, **Opportunity Type**, **Lead Source**.

In each entry, pick the field in **Field**. **Type** fills in from the field (Currency for Amount, Date for Close Date, Percent for Probability), so leave it as it is. To rename a row, turn on **Custom Label** and type the new text in **Label**, for example `Win chance` for Probability. The entry keeps its field name in the panel list; the new label shows on the grid. Use **Help Text** for a short note shown next to the row label, such as `Probability from the current stage`.

<figure><img src="https://27923732-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1FUd4apB9YHgCEMUFbVb%2Fuploads%2FOJfCyDpfgf6UesgDk3Id%2Frecord-grid-compare-records-side-by-side-with-record-grid-row-fields.png?alt=media" alt="Record Grid property editor with Data Source set to Variable, Column Header Field set to Opportunity Name and the Probability entry open under Row Fields, showing Type Percent, Custom Label Win chance and a help text" width="320"><figcaption><p>Variable mode: the collection, the column heading, and one Row Fields entry opened.</p></figcaption></figure>
{% endstep %}

{% step %}

### Label the grid

In the **Header** group, set **Title** to `Open deals`. In the Properties tab, set **Row Label Header** to `Field`: it fills the empty top-left cell above the row labels.

With three deals, the default **Records Per Page** of 5 shows them all on one page. An account with more open deals gets chevrons in the header to page through the rest.
{% endstep %}

{% step %}

### Save and test

Save the flow and run it from an account with open opportunities, or click **Debug** and enter an account Id in `recordId` ([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)).

The screen shows one column per open opportunity, headed by its name and ordered by close date. Six rows run across them, from Amount down to Lead Source, with amounts as currency and Probability as a percentage, under `Win chance` if you renamed it. The row labels stay pinned on the left when the grid scrolls sideways.
{% endstep %}
{% endstepper %}

{% hint style="info" %}
To let the manager adjust Amount, Close Date or Stage right in the grid and save, continue with [Edit and save values in a Record Grid](https://docs.avonnicomponents.com/flow/tutorials/components/record-grid/edit-and-save-values-in-a-record-grid.md).
{% endhint %}

## Troubleshooting

<details>

<summary>The grid is empty</summary>

The Get Records element found nothing, so the collection is empty when the screen opens. Check that `recordId` holds an account Id (in **Debug**, the input variable must be filled), and that the account has opportunities that are not closed. Check also that **Records Collection** points at that element's output.

</details>

<details>

<summary>Column headings or a row are blank</summary>

The field is not stored on the records. This happens when the Get Records element uses **Choose fields and let Salesforce do the rest** and the field is missing from its list. Add every field used in **Column Header Field** and **Row Fields**, or switch to **Automatically store all fields**.

</details>

<details>

<summary>The deals appear in the wrong order</summary>

The grid keeps the order of the collection. Change the **Sort Order** of the Get Records element.

</details>

## Related tutorials

* [Build a fixed Record Grid with manual data](https://docs.avonnicomponents.com/flow/tutorials/components/record-grid/build-a-fixed-record-grid-with-manual-data.md): the same layout for values that are not stored in Salesforce.
* [Edit and save values in a Record Grid](https://docs.avonnicomponents.com/flow/tutorials/components/record-grid/edit-and-save-values-in-a-record-grid.md): let the manager change the deals in place.
* [Send edited Record Grid rows to Apex or a Decision](https://docs.avonnicomponents.com/flow/tutorials/components/record-grid/send-edited-record-grid-rows-to-apex-or-a-decision.md): act on what the manager changed after the screen.


---

# 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/record-grid/compare-records-side-by-side-with-record-grid.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.
