Newer Version Available

This content describes an older version of this product. View Latest

force:navigateToRelatedList

Navigates to the related list specified by parentRecordId.

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}
Each object supports a subset of related lists. The page layout editor shows the related lists supported for each object. For example, account records support these related lists: assets (Assets), cases (Cases), contacts (Contacts), opportunities (Opportunities), among many others.

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.

This event is handled by the one.app container. It’s supported in Lightning Experience, Salesforce app, and Lightning communities.

Note

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