I have a lightning web component that it's data needs to be updated whenever the record is saved.

Is it possible to trigger a function\component refresh when the record is save?


If you are using standard lightning components like record-edit-form or record-form or getRecordUi - All of them use lightning-data-services. So, if the same record is updated in one place, it will be automatically updated in all other places.

However, if you are call Apex Method Imperatively, you can use refreshApex


@Dana, as shown in the How to get an LWC component on a record page to refresh when that page is updated, it works fine for record update anywhere (for lightning data service)

  • I have the same scenario - the user edits the data via the page for the record and saves the update. I then have an LWC on a tab in the record page and it doesn't get refreshed. The component has nothing to do with the editing of the record, but appears on the same flexipage. It doesn't get updated when the record's details update. – Phil W Aug 21 '19 at 10:01
  • @PhilW, I just checked exactly the scenario you told. I used record-edit-form and its updating when updated from record details. Can you pls create a question in detail if what I did is not correct? – salesforce-sas Aug 21 '19 at 10:06
  • @salesforce-sas The specific scenario is that i have a progress bar, that it's percentage should be updated once a few fields are not blank. So there is a calculation function that should run every time a record is saved. – Dana Griff Aug 21 '19 at 10:10
  • @DanaGriff can you edit the question and give more info and codesnippets? – Pranay Jaiswal Aug 21 '19 at 10:11
  • @Pranay jaiswal There is no snippet because i dont know how to trigger a function on record save. – Dana Griff Aug 21 '19 at 11:03

You can call both cacheable and non-cacheable Apex methods imperatively. To refresh the cache for a cacheable method, call the method again. Refresh View works for wire and aura components only.


I hope you'll find this useful but it helped me after long hours of searching ...

Instead of wiring your LWC to a lightning component to call forceRefresh you can use this JS function to reload your browser page, which will discharge the component.

// you can call this after your success toast message. 

// Also, you can add a JS delay.

Scenario: LWC to create multiple related records from a parent object (no updates to the parent required). Challenge: After each record is saved I needed the fields on the component to be cleared out to be able to create the next record with new data. (No Apex involved)

  • 1
    Although this technically works, this forces the whole application and page to refresh, this is a pretty poor user experience compared to the native methods of communicating with the rest of the components – Mattisdada Dec 8 '20 at 0:40

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.