I have an LWC component in which I'm displaying list of records in table format. I've implemented auto save functionality as well. If some user is making changes to a row and at the same time the current user tries to make changes to the same row, I want the current user to get notified not to make any changes. It is almost similar to the excel sheet that we edit in Microsoft Teams(it usually tell us who is editing the same document). Is there any possibility to achieve this? Thanks in advance.
1 Answer
As soon as page loads query the data with SystemModStamp
and keep it in local variable or pass it along with your data to Client side.
When doing DML, just before doing a DML pass this data back to server side(Apex) and query the SystemModStamp
again.
If it matches then no one has changed the data. If not then someone has updated the data and throw error.