I will start by saying "This way lies madness" only because you will get into increasingly annoying corner cases. Things like - Team 2 started working their task, then Team 1 decides to edit, so what happens to what Team 2 is doing? Or Team 1 started editing, but didn't finish the task. They expected their updates to be used, but they weren't because they didn't submit.
Before we try and solve all that, lets solve the problem you asked. I'll assume you have the lock out working already. What I would do is just modify that a bit. The lock should have, in addition to the locked state a "Last Updated" column. When Team 1 is working their task I would have a ajax call from the client every X minutes (lets say 5) that is simply updating that time window. When Team 2 tries to run the task we are checking 2 things , "Is it locked" and "How long since last update?" If it is locked but the update is out of date, you log that, unlock, and proceed, because the client must no longer be communicating with the server, so we will assume an unclean close.
To solve more of the use cases what you really need is a version ID on the data we are working with, where the update from a given user will only be accepted if the version in the DB is the one they are editing. If it isn't then you have 2 choices - a) say "Sorry you have to redo your work" b) write a reconcile screen that preserves their changes but shows them the data that changed while they were working so that they can try and rework. The 2nd option is going to be way easier if you are discerning with your data structures and separate the data (Business Object) that Team 1 can edit from the data that Teams 2 and 3 are editing, so that it is far easier to load Team 1's update and preserve what was done by Team 2.
Also note - you really need to write your coach so that it is using an AJAX call to populate the data on load from the source of truth. If you don't do this then the values used for the user will be the ones that existed when the task started (unless you are using Shared Business Objects). If you don't do this and the following steps happen -
- Team 2 opens the task but does not complete. (Postpones or closes browser)
- Team 1 opens their task, modifies data. Saves and closes.
- Team 2 opens up their task again and continues their work, completing the task.
If you didn't use an AJAX service in an onload event to populate the data (or a SBO I think), the data Team 2 would see in step 3 would be the values they saw when they loaded the task the first time, even though the underlying data changed in the Source of truth.
------------------------------
Andrew Paier
------------------------------