How to display a short term lock in a view?
Hello,
I discovered recently the two checkin/checkout modes in sharepoint.
The long term ckeckout that the user choose explicitly to have and the short term check out when the user open an office document for modification.
This article describe the differences between the two modes: http://blogs.technet.com/harikumh/archive/2008/05/28/check-out-feature-of-sharepoint-2007.aspx
The short term checkout is perfect for my client needs. He doesn't want to checkout a document every time he opens it + a lot of user doesn't understand why to check-in a document when they have done their works.
Here is my problem: I would like to display the short term lock in my document library the same way the long term lock information is displayed.
By code I'm able to see who has acquired the lock and if it is a short term or long term lock:
SPFile.SPCheckOutStatus
The column "CheckedOutBy" in by document library does not display anything for the short term lock. The document icon is not change to display a lock on it.
So I'm searching for an idea, how to be able to display this information in my view?
Best Regards,
Py
November 21st, 2009 9:10am
Hi Shrivallabh,
Sounds good, but are you sure that ItemCheckedOut is triggered by short-term lockout? I have serious doubts...
Should be checked.
Peter
November 21st, 2009 7:06pm
Thanks a lot for the idea. I will check tomorrow if this solution is working.
I hope the event is triggered. (please please)
Best regards,
Py
November 22nd, 2009 9:27pm
The hope is the last to die! :-)
Peter
November 23rd, 2009 2:28am
And the hope has just died :-(
No event is triggered for a short term lock.
This solution is not possible...
I wonder why this information is not displayed in the list and not present in the metadata?
Py
November 23rd, 2009 9:12am
Hello,
A short term lock is an implicit checkout. It is put by an external application like MSOffice when a document is modified.
"We have 2 kinds of Check outs, Short term and long term. If you click the drop-down of a document in aDoc lib and choose check out, that is a long term. When Word opens the document in Read-Write mode, it places a short term checkout on the document."
I've also discovered that this lock can be access by the SPFile.properties["vti_sourcecontrollockexpires"] metadata. The problem is this metadata can't be access from a view.
Py
November 23rd, 2009 10:07am
Thank you for your help Shrivallabh.
I've also read this article. As you can see, they use the ItemCheckoutEvent to prevent user to make some "long term check out" and use ItemUpdatingEvent to prevent user to save modification after a "short term check out". No solution is given to catch a short term check out.
Py
November 23rd, 2009 12:09pm
Hi Peter,
This is a solution for sure.
The problem is that for every item in the list, the webservice will be called. Imagine that every users got 30 items in average in their libraries, the web service will be call 30 times for every page displaying the list (for every filter, every sort,...).
I'm sure that it is theoretically possible. But I'm not confident with the performance impact.
Tell me if I'm correct.
Thanks,
Py
November 23rd, 2009 2:44pm
Hi,
I agree with you, but that is not necessary. You can include the JavaScript block in the HeaderPattern, then your script iterates through all the items that are rendered by DisplayPattern where you should include the IDs only, aggregate the IDs into an XML for example, pass back the XML to your web service. It returns the response as ID-vti_sourcecontrollockexpires pairs (can be simple XML as well), then your script injects the short termcheck-out times for the IDs these are related to.
Alternative solution is to create a custom column for the files, and create a HttpModule that capture when a specific file is opened, and if the file has this custom column, then updates its value using the value stored in the vti_sourcecontrollockexpires property
About HttpModule:
Custom HttpModule Example
http://msdn.microsoft.com/en-us/library/aa719858(VS.71).aspxHTTP Modules
http://msdn.microsoft.com/en-us/magazine/cc301362.aspxHTTP Handlers and HTTP Modules in ASP.NET
http://www.15seconds.com/Issue/020417.htmHow To Create an ASP.NET HTTP Module Using Visual C# .NET
http://support.microsoft.com/kb/307996Peter
-
Marked as answer by
pyorg
Monday, November 23, 2009 3:59 PM
November 23rd, 2009 3:22pm
Your imagination has no limit :-) Thanks.
For the first idea: it is still (more) complicated but seems now acceptable regarding performance.
For the second idea: Opening an office document is done through an activex. This activex call some webservices (We can see all the conversation with a proxy like fiddler). A webservice is also called when office is closed. So it should be possible to catch the opening and closing events.
The only problem left is when office or the OS client crash. No webservices is called. I should test with a job if the lock has expired or not.
Again thanks a lot.
I've now two solutions.
Py
November 23rd, 2009 3:59pm
Hi,
Thanks for your feedback!
"Your imagination has no limit"
Thanks! Unfortunately, my spare time has.I wish I would have time to implement 10% of the ideas I have in my mind. :-(
Let me know if the suggested approaches work or if you have further questions!
Peter
November 23rd, 2009 5:13pm
The relevant SPFile property for short term lock seems to be LockedByUser, LockExpires, etc.
April 28th, 2015 11:44pm