The use of related lists within the Lightning UI has one of the greatest contributions in Salesforce development as it displays and manages connected records. As a result, it delivers users with a streamlined and unified view of associated data. Lightning UI Related List API allows developers to customize and enhance these lists, resulting in more functional, intuitive, and tailored lists.
In this blog, we will walk you through the functionalities of Related List API and its usage through a practical example.

Understanding the Lightning UI Related List API

The module of Lightning UI Related List API addresses several aspects of the related list management with the help of several wire adapters, such as:

getRelatedListInfo: Fetches metadata about a specifically related list.
getRelatedListsInfo: Retrieve the metadata of multiple related lists.
getRelatedListRecords: Collect records from related lists.
getRelatedListCount: Retrieves the count of records in a related list.
getRelatedListRecordsBatch: Fetches records from multiple related lists in batches.
getRelatedListInfoBatch: Retrieves metadata about multiple related lists in batches.

Utilizing getRelatedListCount

One of the key wire adapters within the lightning/uiRelatedListApi module is getRelatedListCount. With the help of this wire adapter, developers can retrieve the record count within a particular related list.

Let’s have a look at its parameters and results:

Parameters:

parentRecordId (Required): Retrieve related list information via parent record ID.
RelatedListId (Required): Includes API names of related list objects, like Contacts, Opportunities, or Cases.
maxCount (Optional): Use the default value of 20 and specify the maximum record numbers to return.

Result:

Count (Integer): The number of records in the related list.
hasMore (Boolean): Indicates whether there are more records beyond the retrieved set.
listReference: Provides a reference to the related list metadata.

Let’s explore a practical implementation of the getRelatedListCount wire adapter within a Lightning Web Component (LWC):

Understanding getRelatedListInfo

The getRelatedListInfo wire adapter is like a gateway that retrieves extensie metadata for related lists.
Let’s delve into its parameters and functionalities:

Parameters:

parentObjectApiName (Required): Fetch related lists through the API name of the parent object.
relatedListId (Required): Related list object’s API name.
recordTypeId (Optional): The ID of the parent record type, if applicable.
fields (Optional): Query the related list’s fields using their API names.
optional fields (Optional): A related list of additional fields is available for querying.
restrictColumnsToLayout (Optional): Determines whether metadata should be retrieved for only the list columns or all columns in the layout.

Implementing getRelatedListInfo

Let’s exhibit how to implement the getRelatedListInfo wire adapter within a Lightning Web Component (LWC):

Understanding getRelatedListInfoBatch

Developers can fetch metadata for a batch of related lists efficiently through getRelatedListInfoBatch.
Let’s examine its parameters and functionalities:

Parameters:

parentObjectApiName (Required): Refers to the API name of the parent object whose related lists you would like to retrieve.
relatedListNames (Required): Array containing API names for related lists supported by the API.

Implementing getRelatedListInfoBatch

Let’s demonstrate how to implement the getRelatedListInfoBatch wire adapter within a Lightning Web Component (LWC):

Understanding getRelatedListRecords

The getRelatedListRecords wire adapter gives an immaculate solution for retrieving records from related lists.
Let’s examine its parameters and functionalities:

Parameters:

parentRecordId (Required): Fetch related lists through the API name of the parent object.
relatedListId (Required): This is the API name of the related list object.
fields (Optional): The API names of the related list’s column fields to query.
optional fields (Optional): Additional fields in the related list to query.
pageSize (Optional): The number of list records to return per page.
sortBy (Optional): An array of field API names to sort the related list by.
where (Optional): The filter to apply to related list records, in GraphQL syntax.

Implementing getRelatedListRecords

Let’s demonstrate how to implement the getRelatedListRecords wire adapter within a Lightning Web Component (LWC):

Understanding getRelatedListRecordsBatch

The getRelatedListRecordsBatch wire adapter enables developers to fetch records for a batch of related lists with ease. Let’s delve into its parameters and functionalities:

Parameter:

parentRecordId (Required): Fetch related lists through the API name of the parent object.

relatedListParameters (Required): Each collection contains an array of related list parameters:

1. relatedListId (Required): This is the API name of the related list object.
2. fields (Optional): You can query the column fields of the related list by using the API names.
3. optional fields (Optional): There are additional fields in the related list for query.
4. pageSize (Optional): The number of list records to return per page.
5. sortBy (Optional): An array of field API names to sort the related list by.
6. where (Optional): The filter to apply to related list records, in GraphQL syntax.

Implementing getRelatedListRecordsBatch

Let’s demonstrate how to implement the getRelatedListRecordsBatch wire adapter within a Lightning Web Component (LWC):

Understanding getRelatedListsInfo

The getRelatedListsInfo wire adapter provides developers with the ability to retrieve metadata for related lists in an object’s default layout. Let’s examine its parameters and functionalities:

Parameter:

parentObjectApiName (Required): Fetch related lists through the API name of the parent object.
recordTypeId (Optional): The ID of the parent record type, if applicable.

Implementing getRelatedListsInfo

Let’s demonstrate how to implement the getRelatedListsInfo wire adapter within a Lightning Web Component (LWC):

The Bottom Line

Developers can easily fetch the metadata for related lists in Salesforce Lightning components by utilizing getRelatedListsInfo from the Lightning UI Related API module. From searching related lists for Accounts, Contacts, Opportunities, or other subjects, the Related API provides an effective approach to retrieving the metadata.
Consequently, it enables developers to manage different scenarios of accuracy and error, ensuring a flawless user experience.
So, unlock the full potential of Lightning components with advanced metadata querying capabilities!

Share This Blog
Related Articles

Salesforce CPQ (Configure, Price, Quote) is a powerful tool that enables businesses to streamline their quoting process by providing advanced configuration options. Among its many features, Multi-Dimensional Quoting (MDQ) stands out as a powerful capability that allows sales teams to create more detailed and flexible quotes for complex products. In this blog, we’ll dive into […]

Read More
Dynamic Search Filters in Salesforce CPQ

Salesforce CPQ (Configure, Price, Quote) is a powerful tool that allows sales teams to generate quotes with speed and accuracy. One of the key features that makes CPQ so flexible is its dynamic search filter capability. In this blog, we’ll explore how you can create dynamic search filters in Salesforce CPQ to make your quoting […]

Read More
How to Create Quote Templates Customization Methods

The objective after completing a quote is usually to produce a precise and expert quote document for clients. However, without the proper procedures in place, quoting can be difficult, error-prone, and time-consuming. Salesforce CPQ (Configure, Price, Quote) streamlines the process and improves quote accuracy by assisting with the setup and administration of quotation papers. By […]

Read More
Boost Performance with a Robust Trigger Framework in Salesforce

Boost Performance with a Robust Trigger Framework in Salesforce If you want to make sure of scalability and performance in the Salesforce development, managing Apex triggers is a must. With a trigger framework, you get a structured approach to organizing and maintaining trigger logic. This way, developers can follow the best practices while maintaining the […]

Read More

When it comes to Salesforce development, efficiently managing and deploying metadata is important to maintain streamlined operations. With the help of Unlocked Package, you can easily achieve this. It is specially designed for business’s internal use and allows businesses to develop and manage modular applications. This blog will walk you through the importance of Unlocked […]

Read More
How Salesforce Data Cloud Streamlines Data Management

The Data Cloud integrates your company’s data onto Salesforce’s Einstein 1 Platform. It provides each team with a comprehensive customer view for a better experience. The Data Cloud consolidates disparate data sources into a unified model, facilitating easy access and comprehension. It encompasses various data types such as web engagement and more from both internal […]

Read More
Our Location worldwide
Indian Flag India
3rd Floor, A-10, Pegasus Tower, Sector 68, Noida, Uttar Pradesh 201301 +91-1203117884
United States of America Flag USA
333 West Brown Deer Road Unit G – 366 Milwaukee WI, USA 53217 +1(262) 310-7818
United Kingdom Flag UK
7 Bell Yard, London, WC2A 2JR +44 20 3239 9428
Canada Canada
HIC Global Solutions INC
43 Lafferty Lane, Richmond Hill, L4C 3N8, CA +1(262) 310-7818