function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Karthik jKarthik j 

How to navigate to the related list of custom object in LWC

Hi All,

I have a requirement to navigate to the related list of the custom object in lwc. I am sharing my code below.

handleClick(){
console.log('recordId>'+this.recordId);
this[ NavigationMixin.Navigate ]( {
type: 'standard__recordRelationshipPage',
attributes: {
recordId: this.recordId,
objectApiName: 'FreshDesk_Ticket__c',
relationshipApiName: 'SRF_SPR__r',
actionName: 'view'
}
} );
}

The above code is taking me to the below page instead of related list.
User-added image

If the child object is standard one you can write object name by adding extra 's' at the end, but how to do it with custom object?

Any help would be appreciated.
SubratSubrat (Salesforce Developers) 
Hello Karthik ,

Requesting you to visit this Blog once for your requirement -> https://www.salesforcebolt.com/2022/09/uiRelatedListApi-get-related-list-metadata-and-records-data-salesforce.html

Hope it helps !
Karthik jKarthik j
Hi Subrat,

Thank you for your reply,
The blog link which you have shared explains how to display RelatedList data, but my requirement is to navigate to the standard related list of the custom object rather than displaying the related list data.
Karthik jKarthik j
I got the answer for this requirement.
Just posting the answer here, To help those who might stucked with the same problem.

handleClick(){
window.open(window.location.origin+'/lightning/r/'+this.recordId+'/related/SRF_SPR__r/view','_self');
}