I have a Lightning Data Table, in which I have edit button to edit the record. Lightening Data Table

Data in the lightning table is loaded in connectedCallBack()

connectedCallback() {
    // Column configuration
    const RecordId = this.recordId;
    .then(result => {
        this.value = JSON.parse(JSON.stringify(result));
    .catch(error => {

On click of edit button, I call navigationMixin.Navigate()

handleRowAction( event ) {
    const actionName = event.detail.action.name;
    const row = event.detail.row;
    if(actionName =='edit'){
            type: 'standard__recordPage',
            attributes: {
                recordId: row.Id,
                objectApiName: 'Object_Name__c',
                actionName: 'edit'

        console.log('Tried calling refreshApex');  

        console.log('Tried calling fetch records again');

What I tried:

  • Tried calling refreshApex()
  • Tried calling fetchRecords() again

But I am not able to refresh the data in the table. I want to refresh the data table's data after edit.

  • 1
    You want your custom component to react and refresh after edit is made in standard edit page (where user is being redirected)? – patryk May 22 '20 at 12:17
  • @patryk Yes, want to refresh the component. – Rashi Neema May 22 '20 at 12:35
  • I posted answer for you, does it solves your problem? – patryk May 26 '20 at 6:43
  • PubSub did the thing. – Rashi Neema Sep 22 '20 at 9:13

To achieve that you need to combine EMP Api, and Platform Events. Basicly you need to implement EMP Api listener in your LWC component, that will be listening for platform events. And in your SObject trigger you need to write Apex that will fire Platform Event always when record is edited. Then LWC will be notified that Platform event occurs, and you can invoke refreshApex() to reflect changes in your datatable.

My samples of code, feel free to use them, and ask any questions if something is not clear, LWC:

subscription = {};
CHANNEL_NAME = '/event/Refresh_Record__e';
connectedCallback() {
    subscribe(this.CHANNEL_NAME, -1, this.handleEvent).then(response => {
        console.log('Successfully subscribed to channel);
        this.subscription = response;

    onError(error => {
        console.error('Received error from server: ', error);

handleEvent = event => {
    const refreshRecordEvent = event.data.payload;
    if (refreshRecordEvent.Record_Id__c === this.recordId && refreshRecordEvent.User_Id__c === currentUserId) {
        this.dispatchEvent(new CustomEvent('refreshrecord'));

disconnectedCallback() {
    unsubscribe(this.subscription, response => {
        console.log('Successfully unsubscribed');


trigger AccountTrigger on Account (after insert, after update) {
List<Refresh_Record__e> refreshRecordEvents = new List<Refresh_Record__e>();
for (Account account : Trigger.new) {
    refreshRecordEvents.add(new Refresh_Record__e(
            Record_Id__c = account.Id,
            User_Id__c = UserInfo.getUserId()


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.