+ Start a Discussion
Phuc Nguyen 18Phuc Nguyen 18 

NavigationMixin.Navigate not redirecting

Hello All,
I have a LWC wrapped inside an aura component.
This is used in a Quick action.
I am trying to redirect to the newly created child record but the page save but does not redirect.  It stays on the parent record.
Code is called on success:
import {CurrentPageReference,NavigationMixin} from 'lightning/navigation'   

export default class GetValueInLWC extends NavigationMixin (LightningElement)  {

this[NavigationMixin.Navigate]({
                type: 'standard__recordPage',
                attributes: { 
                     recordId: event.detail.id,
                     objectApiName: 'Payment_Term__c', 
                     actionName: 'view'
                } 
            });
I know I am getting the new record id but it does not redirect.  Is it becuase the LWC is wrapped in an aura component?  What are my options?
Thanks,
P
 
Best Answer chosen by Phuc Nguyen 18
AnudeepAnudeep (Salesforce Developers) 
I don't see any issues with the code. You can try checking if other redirections are working fine in this context for example: 
 
//Navigate to home page
    navigateToHomePage() {
        this[NavigationMixin.Navigate]({
            type: 'standard__namedPage',
            attributes: {
                pageName: 'home'
            },
        });
    }

If none of the redirections work it could be because it is wrapped in an aura component and it does not work that way

All Answers

Venu9999Venu9999
Hi 

You have to write navigation logic on parent aura component not on lwc. In Lwc, after save success you need to invoke aura method. In this method you have to write navigation logic.
AnudeepAnudeep (Salesforce Developers) 
I don't see any issues with the code. You can try checking if other redirections are working fine in this context for example: 
 
//Navigate to home page
    navigateToHomePage() {
        this[NavigationMixin.Navigate]({
            type: 'standard__namedPage',
            attributes: {
                pageName: 'home'
            },
        });
    }

If none of the redirections work it could be because it is wrapped in an aura component and it does not work that way
This was selected as the best answer