Within a Lightning Experience custom detail page app, using the force:navigateToRelatedList Lightning Aura event may result in errors. When the force:navigateToRelatedList event fires, the expected behavior is to navigate to a new page displaying all records for a related list.
Instead, you may see one or both of the following errors:
How the event works in a Lightning Aura component:
In a Lightning Aura component, a link element with an onclick handler calls a controller function (for example, openRelatedList). The controller function retrieves the force:navigateToRelatedList application event, sets the relatedListId to the custom relationship API name (for example, RelationshipName__r) and the parentRecordId from the component's record ID attribute, then fires the event. If the related list is not included in the object's page layout, this event will produce the errors listed above.
In the Component:
<a href="javascript:void(0);" onclick="{!c.openRelatedList}">View all</a>
In the Controller:
openRelatedList: function(component, _event){
var relatedListEvent = $A.get("e.force:navigateToRelatedList");
relatedListEvent.setParams({
"relatedListId": "RelationshipName__r",
"parentRecordId": component.get("v.recordId")
});
relatedListEvent.fire();
}
Always include the related list in the relevant object page layout in order to use the force:navigateToRelatedList Lightning Aura event. This is necessary even when you intend to override the standard page layout with a custom Lightning app page.
Possible Use Cases:
Use Case 1: You do not want to display the default related lists at all.
force:navigateToRelatedList event in the Lightning detail page app.Use Case 2: You want to display some default related lists and some custom components.
force:navigateToRelatedList event in the Lightning detail page app.
000384080

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.