Newer Version Available
force:navigateToRelatedList
To navigate to a related list, set the parent record ID on the parentRecordId attribute and fire the event. This example displays the related cases on a record and assumes that your component implements the force:hasRecordId and flexipage:availableForRecordHome interfaces. It uses the recordId attribute provided by the force:hasRecordId interface. Implementing these interfaces means that you can drag-and-drop the component to the record pages you want via the Lightning App Builder, such that it can navigate to related cases on an account record or contact record page, or any other record pages that support the case related list.
1gotoRelatedList : function (component, event, helper) {
2 var relatedListEvent = $A.get("e.force:navigateToRelatedList");
3 relatedListEvent.setParams({
4 "relatedListId": "Cases",
5 "parentRecordId": component.get("v.recordId")
6 });
7 relatedListEvent.fire();
8}However, not all related lists are automatically available in your org. For example, the Contacts to Multiple Accounts feature must be enabled for the “Related Contacts” (AccountContactRelations) related list to be available. To identify the relatedListId value of a related list, navigate to the related list and observe the URL token /rlName/<relatedListId>/view that’s appended to the Salesforce URL. However, don’t hard code the URL token in your component markup or JavaScript code as it might change in future releases.
| Attribute Name | Type | Description | Required? |
|---|---|---|---|
| parentRecordId | String | The ID of the parent record. | Yes |
| relatedListId | String | The API name of the related list to display, such as “Contacts” or “Opportunities”. | Yes |