Question

I am having problems with the Client Side lock events of SharePoint 2013. When an user edits the document and closes it. The Client Side lock of SharePoint is working on that document.

Is it possible to make a Client Side function that releases the lock so that the user can continue to work on the document?

Thanks

Was it helpful?

Solution

If you mean the short-time locks placed on Office documents by SharePoint, I described a method how to remove such locks using FrontPage Server Extensions (FSE) requests sent via JavaScript in this post. In first step you should invoke the getDocsMetaInfo method to get some info regarding the lock (like its ID, release date, etc.), then construct and post an XML to the CellStorage web service to request the release of the lock.

However, I prefer to release such orphaned locks via PowerShell as described here.

For example (if the file is locked by the current user):

$ft = New-Object System.TimeSpan(10000) 
$file.Lock([Microsoft.SharePoint.SPFile+SPLockType]::Exclusive, "test lock", $ft) 
$file.UndoCheckOut()

or (if the file is locked by another user):

$web = Get-SPWeb http://intranet.contoso.com 
$list = $web.Lists["DocLib"] 
$item = $list.GetItemById(2) 
$file = $item.File 
$userId = $file.LockedByUser.ID 
$user = $web.AllUsers.GetByID($userId) 
$impSite= New-Object Microsoft.SharePoint.SPSite($web.Url, $user.UserToken); 
$impWeb = $impSite.OpenWeb(); 
$impList = $impWeb.Lists[$list.Title] 
$impItem = $impList.GetItemById($item.ID) 
$impFile = $impItem.File 
$impFile.ReleaseLock($impFile.LockId)
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top