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
Brooks Johnson 6Brooks Johnson 6 

passing an Id to Navigate in LWC

Hi Friends, working on my first and very simple Lightning Web Component. The LWC displays information about a parent record on the child record page.  That part is working fine.  But I would like the user to be able to click a button to go to the parent record. I think I have tried every possible permutation to try and pass the record id into the event handler and I can't seem to get it right. I am hoping someone can take a look this and tell me where I am going wrong with my event listener. 
Here is the button
<template>
    <lightning-card title="RelationshipOwner" icon-name="standard:partners">
        <lightning-button
                label="Go to Relationship Owner Record"
                onclick={navigateToOwner}
                class="slds-m-right_x-small"
        ></lightning-button>
Here is the JS
 
/**
 * Created by Admin on 2/14/2019.
 */

import { LightningElement, api, wire } from 'lwc';
import { NavigationMixin } from 'lightning/navigation';
import { getRecord, getFieldValue } from 'lightning/uiRecordApi';
import Owner_Id from '@salesforce/schema/Contact.New_Relationship_owner1__c';
const owner_fields = [Owner_Id];
export default class relationshipowner extends NavigationMixin(LightningElement) {
@api recordId; // relationship owner id
@wire(getRecord, { recordId: '$recordId', fields: owner_fields })
    contact;
    navigateToOwner() {
        this[NavigationMixin.Navigate]({
            type: 'standard__recordPage',
            attributes: {
                recordId: Owner_Id,
                objectApiName: 'relationship_owner__c',
                actionName: 'view'
            }
        });
    }
    get ownerId() {
        return getFieldValue(this.contact.data, Owner_Id);
    }


}


 
Raj VakatiRaj Vakati
Small mistake i guess .. Try this code and let me know 
 
/**
 * Created by Admin on 2/14/2019.
 */

import { LightningElement, api, wire } from 'lwc';
import { NavigationMixin } from 'lightning/navigation';
import { getRecord, getFieldValue } from 'lightning/uiRecordApi';
import Owner_Id from '@salesforce/schema/Contact.New_Relationship_owner1__c';
const owner_fields = [Owner_Id];
export default class relationshipowner extends NavigationMixin(LightningElement) {
@api recordId; // relationship owner id
@wire(getRecord, { recordId: '$recordId', fields: owner_fields })
    contact;
    navigateToOwner() {
        this[NavigationMixin.Navigate]({
            type: 'standard__recordPage',
            attributes: {
                recordId: this.contact.New_Relationship_owner1__c,
                objectApiName: 'relationship_owner__c',
                actionName: 'view'
            }
        });
    }
    get ownerId() {
        return getFieldValue(this.contact.data, Owner_Id);
    }


}