I had a client that wanted to only allow one user to maintain an order record at any given time. When a user is in an order we will set a field to the user that is using the order so we can tell anybody being locked out who currently has the lock. For some applications it is fine to simply set this lock in one location where the user enters the order and unset the lock in another location when finishing the order. Similarly to WebSmart’s Change Management, we know this can often result in orphaned locks over time if the browser is ended abnormally. In this case even the simple act of the user closing the browser will not trigger the unlock.
There is one gotcha with this approach though. For some reason in Chrome right now the “unload” event is not working for this code. Because of this we need to use ‘window.onbeforeunload’ instead.
xl_AttachEvent(window, “load”, WindowLock);
//xl_AttachEvent(window, “unload”, WindowUnlock);
window.onbeforeunload = WindowUnlock;
// Lock this order if an order number exists
// Unlock this order if an order number exists