Skip to main content
Navigate to related lists on a parent record page, such as viewing all Contacts related to an Account.

Source

force-app/main/default/lwc/navToRelatedList/navToRelatedList.js

Usage

import { LightningElement, wire } from 'lwc';
import { NavigationMixin } from 'lightning/navigation';
import getSingleAccount from '@salesforce/apex/AccountController.getSingleAccount';

export default class NavToRelatedList extends NavigationMixin(
    LightningElement
) {
    @wire(getSingleAccount) account;

    navigateToRelatedList() {
        this[NavigationMixin.Navigate]({
            type: 'standard__recordRelationshipPage',
            attributes: {
                recordId: this.account.data.Id,
                objectApiName: 'Account',
                relationshipApiName: 'Contacts',
                actionName: 'view'
            }
        });
    }
}
Extend your component with NavigationMixin to access navigation capabilities:
export default class NavToRelatedList extends NavigationMixin(
    LightningElement
) {
    // component code
}

PageReference

type
string
required
Set to standard__recordRelationshipPage for related list pages
attributes.recordId
string
required
The ID of the parent record
attributes.objectApiName
string
required
The API name of the parent object (e.g., ‘Account’, ‘Contact’)
attributes.relationshipApiName
string
required
The API name of the related list. For standard relationships, use the plural child object name (e.g., ‘Contacts’, ‘Opportunities’). For custom relationships, use the relationship name from the object definition
attributes.actionName
string
required
Set to view to display the related list

Finding Relationship API Names

Standard Relationships

Common standard relationship names:
  • Contacts - Contacts related to an Account
  • Opportunities - Opportunities related to an Account
  • Cases - Cases related to an Account or Contact
  • ActivityHistories - Completed activities
  • OpenActivities - Upcoming activities

Custom Relationships

For custom relationships, find the relationship name in Setup:
  1. Navigate to Object Manager
  2. Select the parent object
  3. Click on Fields & Relationships
  4. Find the relationship field
  5. Use the “Child Relationship Name” value

Examples

Account Contacts

this[NavigationMixin.Navigate]({
    type: 'standard__recordRelationshipPage',
    attributes: {
        recordId: accountId,
        objectApiName: 'Account',
        relationshipApiName: 'Contacts',
        actionName: 'view'
    }
});

Account Opportunities

this[NavigationMixin.Navigate]({
    type: 'standard__recordRelationshipPage',
    attributes: {
        recordId: accountId,
        objectApiName: 'Account',
        relationshipApiName: 'Opportunities',
        actionName: 'view'
    }
});

Key Features

  • Navigate to related lists on record pages
  • Supports standard and custom relationships
  • Type-safe navigation with PageReference
  • Works with all standard and custom objects

Build docs developers (and LLMs) love