---
schema_version: "1"
id: 71f0a1f6f4b7f91466fafa19c5aca9627a7b1e13c37c4b004f0185fe843b07a4
title: Get Related List Metadata
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/graphql-api/graphql/guides/query/query-related-list-info.md
canonical_url: https://developer.salesforce.com/docs/platform/graphql/guide/query-related-list-info.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 51991211cf84d53215e4f0644b434e24cfd56aa412ca061dea46951620968eac
products:
  - GraphQL API
---
# Get Related List Metadata

| AVAILABLE API VERSION |
| --------------------- |
| API v57.0 and later   |

The `relatedListByName` type returns metadata for a related list in a page layout. The response includes metadata describing fields, relationships, the columns in the list, and the list’s sort order.
Only [objects supported by UI API](https://developer.salesforce.com/docs/atlas.en-us.uiapi.meta/uiapi/ui_api_get_started_supported_objects.htm) are available for querying.

Pass in the `relatedListByName` type in the `uiapi` field. For example, to return metadata for the Opportunity related list on the Account object, use `parentApiName: "Account"` and `relatedListName: "Opportunities"`.

```
{
  uiapi {
    relatedListByName(parentApiName: "Account", relatedListName: "Opportunities") {
      # fields
    }
  }
}
```

## Related List Schema

Query `relatedListByName` by following this schema.

```
type UIAPI {
  relatedListByName(parentApiName: String!, relatedListName: String!): RelatedListInfo
}
```

## RelatedListInfo Types and Fields

The `RelatedListInfo` type includes fields for the related list metadata.

```
type RelatedListInfo {
  childApiName: String!
  displayColumns: [ListColumn!]!
  fieldApiName: String!
  label: String!
  orderedByInfo: [ListOrder!]!
  parentApiName: String!
  relatedListName: String!
}
```

The `RelatedListInfo` type contains these fields.

- `childApiName`: The API name of a [supported child object](https://developer.salesforce.com/docs/atlas.en-us.uiapi.meta/uiapi/ui_api_get_started_supported_objects.htm#ui_api_get_started_supported_objects).
- `displayColumns`: All [display columns](#listcolumn) for the related list.
- `fieldApiName`: The API name of the field in the child object that links to the parent object.
- `label`: The related list display label, for example, "Opportunities".
- `orderedByInfo`: [Ordering information](#listorder) for the related list.
- `parentApiName`: The API name of a [supported parent object](https://developer.salesforce.com/docs/atlas.en-us.uiapi.meta/uiapi/ui_api_get_started_supported_objects.htm#ui_api_get_started_supported_objects).
- `relatedListName`: The name of a supported related list for an object, such as Opportunities.

### ListColumn

The `ListColumn` type represents metadata for a column in the related list.

```
type ListColumn {
  fieldApiName: String!
  label: String!
  lookupId: String
  sortable: Boolean
}
```

The `ListColumn` type contains these fields.

- `fieldApiName`: The API name for the column field.
- `label`: The label of the column field.
- `lookupId`: The ID of the column field if the field is a reference. If the field isn’t a reference, the value can be null.
- `sortable`: Indicates whether the column is sortable.

### ListOrder

The `ListOrder` type represents the ordering information for a related list.

```
type ListOrder {
  fieldApiName: String!
  sortDirection: ResultOrder
}
```

The `ListOrder` type contains these fields.

- `fieldApiName`: The API name for the field.
- `sortDirection`: The sort order specified by the [ResultOrder](#resultorder) enum.

## Enumeration Types

The [`ListOrder` type](#listorder) contains an enum definition for the `sortDirection` field.

### ResultOrder

The `ResultOrder` enumeration specifies whether the results are ordered in ascending or descending order.

```
enum ResultOrder {
  ASC
  DESC
}
```

## Example: Query Opportunities Related List Metadata for Account

This example fetches the metadata for the Opportunities related list on an Account.

```
{
  uiapi {
    relatedListByName(parentApiName: "Account", relatedListName: "Opportunities") {
      label
      parentApiName
      childApiName
      relatedListName
      displayColumns {
        fieldApiName
        label
        sortable
      }
    }
  }
}
```

### Example Response for Opportunities Related List Metadata for Account

The previous query returns this response.

```
{
  "data": {
    "uiapi": {
      "relatedListByName": {
        "label": "Opportunities",
        "parentApiName": "Account",
        "childApiName": "Opportunity",
        "relatedListName": "Opportunities",
        "displayColumns": [
          {
            "fieldApiName": "Name",
            "label": "Opportunity Name",
            "sortable": true
          },
          {
            "fieldApiName": "StageName",
            "label": "Stage",
            "sortable": true
          },
          {
            "fieldApiName": "Amount",
            "label": "Amount",
            "sortable": true
          },
          {
            "fieldApiName": "CloseDate",
            "label": "Close Date",
            "sortable": true
          }
        ]
      }
    }
  },
  "errors": []
}
```
