Skip to main content
1 of 3
user avatar
user avatar

Navigate to Contact record detail page from Account object

I'm trying to navigate to contact record page from account object details page.

the scenario is, In Account object there are multiple contacts available. when i click on any of contacts it should open on Contact object details page. I'm tryng it by using Navgigation mixin by passing recordId, but it will open on account objects only can any one try to guide me how to do this

js:

import { LightningElement, track, wire, api } from 'lwc';
import findContacts from '@salesforce/apex/GetContactController.getContacts';
import { NavigationMixin } from 'lightning/navigation';

const DELAY = 300;


export default class GetContactOnAccount extends NavigationMixin(LightningElement) {
    @track searchKey = '';
    @api recordId;
    
    @wire(findContacts, { searchKey: '$searchKey' })
    contacts;

        navigateToNewContactPage() {
                this[NavigationMixin.Navigate]({
                    type: 'standard__recordRelationshipPage',
                    attributes: {
                        recordId: this.recordId,
                        objectApiName: 'Account',
                        relationshipApiName: 'Contacts',
                        actionName: 'view'
                    },
                });
    }

//connectedCallback function is similar to init method in Lightning Components.
    connectedCallback(){
        this.searchKey = this.recordId;
    }



}
user111857