How to refresh cache when using Lightning Navigation in Lightning Web Component in Salesforce?

Please check the following article.

A component calls this[NavigationMixin.GenerateUrl] to get a promise that resolves to the resulting URL. The component can use the URL in the href attribute of an anchor. It can also use the URL to open a new window using the browser API.

Sample Code:

    <lightning-button variant="brand" label="Cancel" onclick={cancel}></lightning-button>

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

export default class NewEmployeeChild extends  NavigationMixin( LightningElement ) {

    @api accountId;

    connectedCallback() {
        this.accountURL = {
            type: 'standard__recordPage',
            attributes: {
                recordId: this.accountId,
                objectApiName: 'Account',
                actionName: 'view'
        this[ NavigationMixin.GenerateUrl ]( this.accountURL )
            .then( url => this.url = url );


    cancel() {

        console.log( 'URL is ' + this.url ); this.url, '_self' );



No comments:

Post a Comment