0

How would I update the data/view of another user when one user makes changes to a record via a lightning-record-form LWC?

For example, User 1 edits an Account record and changes the phone number via the LWC lightning-record-form. User 1 saves the changes, the data is updated on the record page for the Account for User 1. User 2 is viewing that record on another computer and needs to see the changes User 1 just made while viewing the record.

Basically, I'm trying to create a custom UI for viewing and editing records, and I need it to update all other users/browsers/tabs/views when a record is changed. Currently the user who is viewing the record has to refresh or reload the record to see any changes made by other users. Also, if I make a change to a record and have the record open in another browser window or tab, the changes only reflect on the browser window/tab that I used to edit the record and don't show up in the other windows/tabs until I refresh them.

Is this possible to have data automatically refresh in other windows/tabs or for other users without manually refreshing the page? I've been trying to google this but it keeps coming up with "editing multiple users" or "mass updating multiple user accounts".

2 Answers 2

2

the closest thing would the the lightning/empApi module

it provides access to methods for subscribing to a streaming channel and listening to event messages. All streaming channels are supported, including channels for platform events, PushTopic events, generic events, and Change Data Capture events. This component requires API version 44.0 or later.

You could potentially notify users that an update to a record is available, or simply do the update based on the event(s)

1
  • Thank you! I will look into this.
    – dan
    Apr 23, 2021 at 6:05
2

You could turn on Change Data Capture for Account records and within your custom LWC subscribe the AccountChangeEvent using EmpApi Module. It will allow you to capture the updated details in the LWC and you'll need to write logic to update the data accordingly in the UI.

Using Change Data Capture will ensure an event is fired anytime a DML is made on respective record regardless of where it was updated from, be it API, standard screen/ other custom processes etc.

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.