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 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".
1 {
2 uiapi {
3 relatedListByName ( parentApiName : "Account" , relatedListName : "Opportunities" ) {
4 # fields
5 }
6 }
7 }
Related List Schema
Query relatedListByName by following this schema.
1 type UIAPI {
2 relatedListByName ( parentApiName : String !, relatedListName : String ! ) : RelatedListInfo
3 }
RelatedListInfo Types and Fields
The RelatedListInfo type includes fields for the related list metadata.
1 type RelatedListInfo {
2 childApiName : String !
3 displayColumns : [ ListColumn ! ] !
4 fieldApiName : String !
5 label : String !
6 orderedByInfo : [ ListOrder ! ] !
7 parentApiName : String !
8 relatedListName : String !
9 }
The RelatedListInfo type contains these fields.
childApiName: The API name of a supported child object .
displayColumns: All display columns 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 for the related list.
parentApiName: The API name of a supported parent object .
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.
1 type ListColumn {
2 fieldApiName : String !
3 label : String !
4 lookupId : String
5 sortable : Boolean
6 }
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.
1 type ListOrder {
2 fieldApiName : String !
3 sortDirection : ResultOrder
4 }
The ListOrder type contains these fields.
fieldApiName: The API name for the field.
sortDirection: The sort order specified by the ResultOrder enum.
Enumeration Types
The ListOrder type contains an enum definition for the sortDirection field.
ResultOrder
The ResultOrder enumeration specifies whether the results are ordered in ascending or descending order.
1 enum ResultOrder {
2 ASC
3 DESC
4 }
Example: Query Opportunities Related List Metadata for Account
This example fetches the metadata for the Opportunities related list on an Account.
1 {
2 uiapi {
3 relatedListByName ( parentApiName : "Account" , relatedListName : "Opportunities" ) {
4 label
5 parentApiName
6 childApiName
7 relatedListName
8 displayColumns {
9 fieldApiName
10 label
11 sortable
12 }
13 }
14 }
15 }
Example Response for Opportunities Related List Metadata for Account
The previous query returns this response.
1 {
2 "data" : {
3 "uiapi" : {
4 "relatedListByName" : {
5 "label" : "Opportunities" ,
6 "parentApiName" : "Account" ,
7 "childApiName" : "Opportunity" ,
8 "relatedListName" : "Opportunities" ,
9 "displayColumns" : [
10 {
11 "fieldApiName" : "Name" ,
12 "label" : "Opportunity Name" ,
13 "sortable" : true
14 } ,
15 {
16 "fieldApiName" : "StageName" ,
17 "label" : "Stage" ,
18 "sortable" : true
19 } ,
20 {
21 "fieldApiName" : "Amount" ,
22 "label" : "Amount" ,
23 "sortable" : true
24 } ,
25 {
26 "fieldApiName" : "CloseDate" ,
27 "label" : "Close Date" ,
28 "sortable" : true
29 }
30 ]
31 }
32 }
33 } ,
34 "errors" : [ ]
35 }