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
DanishDanish 

LWC Page refresh in Console Navigation App

I have a Console Navigation App. I have added one LWC component to the lightning record page. The component saves some data. On click of Save, I want the page to refresh automatically, so as to display the changes made. Is there any way to implement the same from LWC directly (I don't want to use Aura component) ??

I have tried with "NavigationMixin.Navigate". It works fine with Standard Navigation Apps, but no success in CONSOLE NAVIGATION Apps

PriyaPriya (Salesforce Developers) 

Hi Danish,

Please try using eval.refresh and check if it work. 

If it work please mark it as Best Answer so that it may help others also.

regards,

Priya Ranjan

Prathap SFDCPrathap SFDC
Hi Danish.

If a simple refresh is all you need, you can leverage the web API interface 'window' using javascript in LWC.
In the save button handler use window.location.reload(). 

For more info, refer this MDN doc
https://developer.mozilla.org/en-US/docs/Web/API/Location/reload

Use Navigation mixin only when you want to navigate the user to some other URL.

Hope this helps :)
Yogendra JangidYogendra Jangid
Hi Danish, you can consider implementing platform event to refresh your component with latest data. To know more on how you can use platform event to refresh, go with the below link
https://inevitableyogendra.blogspot.com/p/how-to-refesh-lightning-datatable-after.html

Hope this will resolve your issue. If so please can you mark this as best asnwer. :)
DanishDanish

@Priya,
I think, eval.refresh will make use of Aura component. But I don't want to write one. I wanted to implement refresh directly from LWC.
Is there any way for the same ??

@Pratap SFDC
location.reload() can do a refresh of the entire page. It can be an alternative, if nothing else worked.
I used 'Navigation mixin' as I want to do a component level refresh, not a page refresh.
'Navigation mixin' did work correctly in Standard navigation App, but nothing in Console App.

@Yogendra
Platform event refresh will require creation of 
1. Platform Event
2. Process builder
This will be my last option, if nothing else works.
However, thanks for suggestion
 

deepti Kulkarnideepti Kulkarni
Hii Danish,

Please try this one,

import { LightningElement, api, track, wire } from 'lwc';
import { updateRecord } from 'lightning/uiRecordApi';
import updateAccount from '@salesforce/apex/ApexControllerClass.updateAccount;

export default class lightning-web-component-example extends LightningElement {

      @api recordId;
      handleClick(){
             // Call Apex Method imperatively to update Account record
             updateAccount({accountId: this.recordId}
             ) .then( result => {
                       if (result) {
                                      // Refresh Account Detail Page
                                      updateRecord(
                                                   { fields: { Id: this.recordId }}
                                      )
                       }
            })
     }
}
lot carlot car
German Shepherds can have dwarfism much the same as humans can. Pituitary dwarfism is the most common type and is a genetic disorder dwarf german shepherd https://germanshepherdss.com/dwarf-german-shepherd/