How to restrict user from edit when other user editing record?

Any tips will be appreciated.

Thank you, I’ve already found this feature, but I want to full lock user from editing, when other user in record’s edit mode. So he can’t even choose, which version of record choose. Just lock and that’s all I want to reach.

That feature doesn’t exist out-of-the-box, sorry, you’ll have to program it yourself. And it’s going to be tricky…

You need to save some kind of temporary “lock file” when users enter edit views, and check that to see if any user has previously entered.

The tough part is dealing with abandoned edits, people that go offline or close their tabs in the middle on an edit, and you won’t know if you can clear the lock file, or when you should do it.

Instead of a lock file you can also use a field in the DB, it doesn’t matter, as long as it gets saved server-side.

What kind of db field can I use for that? I think I didn’t clearly understand this idea. I prevent other user from edititing record and show username who is in edit mode now.

I just mean that you create something, somewhere to write that down. A lock file. Or a new field you make for that purpose, somewhere.

It will be easy to register “this record is now going into edit mode by user X”.

It will be very hard, or even impossible, to registre “this record has now finished being edited”. I mean, it will be easy in some cases, but definitely not all.

So I should insta-save record, when user is going to edit mode?

I’m not sure I understand your question, but if I am reading it correctly, I think you’re talking about saving the information “this record is now going into edit mode by user X” in the record itself (thus the need to save it as soon as you start editing).

No, I don’t think that would be a good way to design this feature, it would have many complications. I would save it in a separate table with a reference to the record, or perhaps outside the database, directly in the file system, by creating a lock file in the cache directory.

1 Like

Thank you, I suppose “lock” file will be the best solution for me.