Navigate to Related List


Navigation_ex

<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction,lightning:hasPageReference,lightning:isUrlAddressable" 
                access="global" >
    
    <lightning:navigation aura:id="navigate" />
    
    <lightning:button label="Cases Lightning Related List" onclick="{!c.gotoRelatedListCase}" 
                      variant="brand" />  
    
    <lightning:button label="Contact Lightning Related List" onclick="{!c.gotoRelatedListCon}" 
                      variant="brand" />  
    <lightning:button label="Opportunities Lightning Related List" onclick="{!c.gotoRelatedListOpp}" 
                      variant="brand" />  

</aura:component>


JS
({
    gotoRelatedListCase : function (component, event, helper) {
        var relatedListEvent = $A.get("e.force:navigateToRelatedList");
        relatedListEvent.setParams({
            "relatedListId": "Cases",
            
            "parentRecordId": component.get("v.recordId")
        });
        relatedListEvent.fire();
    },
    gotoRelatedListCon : function (component, event, helper) {
        var relatedListEvent = $A.get("e.force:navigateToRelatedList");
        relatedListEvent.setParams({
            "relatedListId": "Contacts",
            
            "parentRecordId": component.get("v.recordId")
        });
        relatedListEvent.fire();
    }, 
    
    gotoRelatedListOpp : function (component, event, helper) {
        var relatedListEvent = $A.get("e.force:navigateToRelatedList");
        relatedListEvent.setParams({
            "relatedListId": "Opportunities",
            
            "parentRecordId": component.get("v.recordId")
        });
        relatedListEvent.fire();
    },
})

O/P

Note: Should add component to record page




Comments

Popular posts from this blog

Lightning Grid Custom Datatable

Comparing Two Values Using Aura If

Dynamic Standard Datatable Using Fieldset