Microsoft Secure Tech Accelerator
Apr 03 2024, 07:00 AM - 11:00 AM (PDT)
Microsoft Tech Community
This item cannot be declared a record because it is checked out.
Published Feb 08 2019 12:54 PM 779 Views
Microsoft

First published on MSDN on Aug 20, 2014

A customer recently asked me to help with a problem in a record center in SharePoint 2010. They had one specific record that seemed like it was stuck in some state where it couldn't be modified. The UI showed either of the following two messages when we tried to delete or modify it.

This item cannot be declared a record because it is checked out.

The item cannot be deleted, moved, or renamed because it is either on hold or is a record which blocks deletion.

Digging into the ULS logs, we found the record was set to locked as read-only, even though the properties of the document showed it wasn't read only.

01/01/2014 11:11:11.11    w3wp.exe (SERVERNAME)    0x044C    SharePoint Foundation    General    8kh7    High    This item cannot be updated because it is locked as read-only.    bad285fd-e35c-4e8b-8e1f-a61589a4e689
01/01/2014 11:11:11.11    w3wp.exe (SERVERNAME)    0x044C    SharePoint Foundation    General    8kh7    High    Stack trace: onetutil.dll: (unresolved symbol, module offset=00000000000A22A1) at 0x000007FEEC2322A1 onetutil.dll: (unresolved symbol, module offset=00000000000A3461) at 0x000007FEEC233461 owssvr.dll: (unresolved symbol, module offset=0000000000009002) at 0x000007FEE56A9002 owssvr.dll: (unresolved symbol, module offset=0000000000037941) at 0x000007FEE56D7941 mscorwks.dll: (unresolved symbol, module offset=00000000002BB727) at 0x000007FEF8F1B727 Microsoft.SharePoint.Library.ni.dll: (unresolved symbol, module offset=00000000000DFA24) at 0x000007FEE3D6FA24 Microsoft.SharePoint.ni.dll: (unresolved symbol, module offset=0000000001AFA6DD) at 0x000007FEE8BCA6DD Microsoft.SharePoint.ni.dll: (unresolved symbol, module offset=0000000001C68563) at 0x000007FEE8D38563 Microsoft.SharePoint.ni.dll: (unresolved symbol, module offset=0000000001C686C3) at 0x000007FEE8D386C3    bad285fd-e35c-4e8b-8e1f-a61589a4e689
01/01/2014 11:11:11.11    w3wp.exe (SERVERNAME)    0x044C    SharePoint Foundation    General    2mx9    Verbose    Ignore exception 'Microsoft.SharePoint.SPException: This item cannot be updated because it is locked as read-only. ---> System.Runtime.InteropServices.COMException (0x81020089): This item cannot be updated because it is locked as read-only.
at Microsoft.SharePoint.Library.SPRequestInternalClass.DeleteItem(String bstrUrl, String bstrListName, Int32 lID, UInt32 dwDeleteOp, Guid& pgDeleteTransactionId)
at Microsoft.SharePoint.Library.SPRequest.DeleteItem(String bstrUrl, String bstrListName, Int32 lID, UInt32 dwDeleteOp, Guid& pgDeleteTransactionId)     --- End of inner exception stack trace ---
at Microsoft.SharePoint.SPGlobal.HandleComException(COMException comEx)     at Microsoft.SharePoint.Library.SPRequest.DeleteItem(String bstrUrl, String bstrListName, Int32 lID, UInt32 dwDeleteOp, Guid& pgDeleteTransactionId)
at Microsoft.SharePoint.SPListItem.DeleteCore(DeleteOp deleteOp)     at Microsoft.SharePoint.SPListItem.Recycle()
at Microsoft.SharePoint.SPListItem_Proxy.InvokeMethod(Object obj, String methodName, XmlNodeList xmlargs, ProxyContext proxyContext, Boolean& isVoid)
at Microsoft.SharePoint.Client.ClientMethodsProcessor.InvokeMethod(Object obj, String methodName, XmlNodeList xmlargs, Boolean& isVoid)
at Microsoft.SharePoint.Client.ClientMethodsProcessor.ProcessMethod(XmlElement xe)
at Microsoft.SharePoint.Client.ClientMethodsProcessor.ProcessOne(XmlElement xe)
at Microsoft.SharePoint.Client.ClientMethodsProcessor.ProcessStatements(XmlNode xe)
at Microsoft.SharePoint.Client.ClientMethodsProcessor.ProcessExceptionHandlingScope(XmlElement xe)' when executing '<ExceptionHandlingScopeSimple Id="0" xmlns=" http://schemas.microsoft.com/sharepoint/clientquery/2009" ><ObjectPath Id="3" ObjectPathId="2" /><ObjectPath Id="5" ObjectPathId="4" /><ObjectPath Id="7" ObjectPathId="6" /><ObjectPath Id="9" ObjectPathId="8" /><ObjectPath Id="11" ObjectPathId="10" /><Query Id="12" ObjectPathId="10"><Query SelectAllProperties="false"><Properties><Property Name="FileLeafRef" ScalarProperty="true" /></Properties></Query></Query><Method Name="Recycle" Id="13" ObjectPathId="10" /></ExceptionHandlingScopeSimple>'.    bad285fd-e35c-4e8b-8e1f-a61589a4e689

To fix this issue, I found some code that helped removed the lock. Take a look at the sample code, and hopefully it can fix the issue for you.

We leveraged the UndeclareItemAsRecord function.
http://technet.microsoft.com/en-us/subscriptions/microsoft.office.recordsmanagement.recordsreposito...


private static void UndeclareDeclare()
{
string recordCenterRootWebURL = "http://sp2010:1123/sites/records";
using (SPSite site = new SPSite(recordCenterRootWebURL))
{
using (SPWeb web = site.OpenWeb())
{
for (int i = 0; i < 300; i++)
{
string listName = "Administration";
SPList list = web.Lists[listName];
int listItemId = 4; // ID of the list item declared as record
SPListItem item = list.GetItemById(listItemId);
// Undeclare item as record
Microsoft.Office.RecordsManagement.RecordsRepository.Records.UndeclareItemAsRecord(item);
item = list.GetItemById(listItemId);
// Declare item as record
Microsoft.Office.RecordsManagement.RecordsRepository.Records.DeclareItemAsRecord(item);
Console.WriteLine(i);
}
}
}
}



If you can't undeclared the item as a record, it might be possible to turn off the lock. There's a method in the records management code by called Records.BypassLocks that might do the trick.
http://technet.microsoft.com/en-us/subscriptions/microsoft.office.recordsmanagement.recordsreposito...


private static void TouchItem()
{
using (SPSite site = new SPSite(recordCenterRootWebURL))
{
using (SPWeb web = site.OpenWeb())
{
SPList list = web.Lists[listName];
SPListItem item = list.GetItemById(listItemId);
Records.BypassLocks(item, delegate(SPListItem item1)
{
item1.File.CheckOut();
item1.Update();
item1.File.CheckIn("hello");
});
//Console.WriteLine("Done update");
}
}
}



There are a bunch of reasons why locks can get stuck, and some have to do with configuration and the ways records management works. Please make sure you understand your scenario, before applying a fix like this.

Version history
Last update:
‎Apr 28 2020 12:25 PM
Updated by: