concurrent users and before commit object

1
I have an object (A) which I want to make sure that 2 concurrent users can not update it at the same time . I added an integer attribute to that object which will indicate version of update. and using before commit micro-flow I compare between the current object and its database object(retrieve the same object from DB )--> if they are equal that it is mean there is no other user made any update from the record that the user has read and thus set attribute=attribute+1 and return true to allow committing the object, otherwise(they are not equal) return false to prevent commit. Scenario: 1- user1 press edit to object A while the attribute number=1 2 -user2 press edit to object A while the attribute number=1 3- user1 press save (and before commit I compared between the current object with attribute=1 and database object with attribute=1 and thus the attribute number=2 and return true to commit object 4- user2 press save( and now it is supposed that the attribute of database object = 2 ,while current object still 1 and thus show him error message and return false to prevent commit) but unfortunately I found the current object becomes equal 2 as the database object and thus leads to commit the object by user2 How the current object is updated with the database value without informing user? And If I want to apply this Idea in the micro-flow, what should I do or I have to do it in the java-action?
asked
2 answers
1

I recommend you use the community commons module instead of creating a locking mechanism yourself. You can get this from the Appstore.

answered
0

what I understand from the locking mechanism in the community commons module that I have to apply it in many screens for my object

  • I hope if i can apply my idea as it will be done once (before commit) but I just wonder when a user1 edit an object a user2 can see the changes in its current object
answered