1

I am trying to use the navigation to custom sObject record edit page by passing recordid as mentioned in the document. However, it says "it is not a function".

Any thoughts?

import { NavigationMixin } from 'lightning/navigation';

navigateToCorpconEdit(row) {
        let { linkName } = row;            
        let recordid = linkName.substr(1);

        this[NavigationMixin.Navigate]({
            type: 'standard__recordPage',
            attributes: {
                recordId: recordid,
                objectApiName: 'npe5__Affiliation__c',
                actionName: 'edit'
            },
        });
    }

Error:

[this[h.NavigationMixin.Navigate] is not a function]

2
  • It looks like you have not put your method in a class, I don't know if you are abbreviating your code, but you need to have an export default class NavigateToSomething extends NavigatoinMixin(LightningElement){ ... } . You will also need to include import { LightningElement } from 'lwc'; – Kevin Hill Jun 21 '19 at 2:44
  • 5
    Does this answer your question? LWC Navigation: "this[f.NavigationMixin.Navigate] is not a function" – Bow-chicawow-ers Jun 30 '20 at 19:09
3

I added a comment but it looks like you are missing the export, and extending the MixIn. So your code needs to look more like this:

import { LightningElement } from 'lwc';
import { NavigationMixin } from 'lightning/navigation';

export default class NavToSomething extends NavigationMixin(LightningElement) {
    navigateToCorpconEdit(row) {
        let { linkName } = row;            
        let recordid = linkName.substr(1);

        this[NavigationMixin.Navigate]({
            type: 'standard__recordPage',
            attributes: {
                recordId: recordid,
                objectApiName: 'npe5__Affiliation__c',
               actionName: 'edit'
            },
        });
    }
}
1
  • thank you, I missed extends the NavigationMixin, good learning..:) – Ajay Jun 21 '19 at 2:52

Not the answer you're looking for? Browse other questions tagged or ask your own question.