LWC NavigationMixin Not Working – Troubleshooting Guide

lightninglightning-web-componentsnavigationvisual-workflow

i am trying to create a custom footer for a flow. While trying to navigate to a list page of Survey object the Navigation is not working, Any help would mean a lot.

Thanks!!

<template>
    <div>
        <footer class="slds-modal__footer"  >
        <lightning-button class="slds-m-right_small"  label="Navigate to Survey" onclick={navigateToListView} >
        </lightning-button>
        <lightning-button class="slds-m-left_small"  label="Next" onclick={handleGoNext}>
        </lightning-button>
    </footer>
    </div>   
</template>


import { LightningElement, api } from 'lwc';
import { FlowNavigationNextEvent } from 'lightning/flowSupport';
import { NavigationMixin } from 'lightning/navigation';

export default class IDS_SendSuveryfooter extends LightningElement {



    handleGoNext() {
            console.log('next event fired')
                //     if (this.availableActions.find((action) => action === 'NEXT')) {
                // navigate to the next screen
            const navigateNextEvent = new FlowNavigationNextEvent();
            this.dispatchEvent(navigateNextEvent);
        }
        //}


    navigateToRecord() {
        console.log('navigate event fired')
            // Navigate to the Contact object's Recent list view.
        this[NavigationMixin.Navigate]({
            type: 'standard__objectPage',
            attributes: {
                objectApiName: 'Survey',
                actionName: 'list'
            },
            state: {
                filterName: 'Recent'
            }
        });
    }
}


Best Answer

For NavigationMixin we need to follow this format in the .js:

 export default class IDS_SendSuveryfooter extends NavigationMixin(LightningElement) {
    ......
    }

Follow the documentation for more information: https://developer.salesforce.com/docs/component-library/bundle/lightning-navigation/documentation