You need to sign in to do that
Don't have an account?
Danish
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
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
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 :)
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. :)
@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
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 }}
)
}
})
}
}