none
Not able to delete file : The file is currently checked out or locked for editing by another user RRS feed

  • Question

  • Hi All,

    We have one file uploaded by customer into the document library.

    The file icon shows as if the file has been checked out by someone. But actually Checked Out To field is empty.

    If I try to check in or discard checkout it is giving above error.

    I tried multiple ways to delete/checkin/checkout it but couldn't succeed using below script.

    $targetWeb = "https://site"

    $targetLibrary = "library/folder"

    $fileName = "Current Permissions Summary_20150624.xls"

     

    $myWeb = Get-SPWeb $targetWeb

    $myLib = $myWeb.GetFolder($targetLibrary)

    $myFile = $myLib.Files | ? {$_.name -eq $fileName}

     

    # for CheckIn use the following line otherwise comment it out with a #

    $myFile.CheckIn("MyCheckIn Comment")

    # or to undo the CheckOut use the line below

    #$targetLibrary.GetFile($myFile).CheckOut()

    $myFile.CheckOut()

    $myFile.UndoCheckOut()

    $myFile.Update()

    Including SPFile object properties for reference.

    EffectiveRawPermissions : FullMask
    EffectiveAuditMask      : None
    Exists                  : True
    Properties              : {vti_categories, vti_nexttolasttimemodified, vti_assignedto, vti_level...}
    ForwardLinks            : {}
    BackwardLinks           : {}
    Title                   : Current Permissions Summary_Updated
    Length                  : 119296
    TotalLength             : 119296
    LengthByUser            :
    Author                  : i:0#.w|****
    ModifiedBy              : i:0#.w|*******
    TimeCreated             : 6/25/2015 3:50:14 AM
    TimeLastModified        : 5/4/2016 1:45:08 AM
    CustomizedPageStatus    : None
    ETag                    : "{5959E59D-AE3F-4953-81DD-E93331A75C2D},4"
    LockType                : None
    LockId                  :
    LockedDate              :
    LockExpires             :
    LockedByUser            :
    CheckOutStatus          : None
    CheckOutType            : None
    CheckedOutDate          :
    CheckOutExpires         :
    CheckedOutBy            :
    CheckedOutByUser        :
    CheckInComment          :
    Generator               :
    CharSetName             :
    ProgID                  :
    UIVersion               : 512
    MajorVersion            : 1
    MinorVersion            : 0
    UIVersionLabel          : 1.0
    ParentFolder            : library/folder
    Url                     : library/folder/Current Permissions Summary_20150624.xls
    UniqueId                : 5959e59d-ae3f-4953-81dd-e93331a75c2d
    ServerRelativeUrl       : /site/library/folder/Current Permissions Summary_
                              20150624.xls
    IconUrl                 : icxls.png
    Name                    : Current Permissions Summary_20150624.xls
    RequiresCheckout        : True
    DocumentLibrary         : Lib
    Versions                : {}
    Item                    : Microsoft.SharePoint.SPListItem
    ListItemAllFields       : Microsoft.SharePoint.SPListItem
    InDocumentLibrary       : True
    Level                   : Published
    IsConvertedFile         : False
    SourceLeafName          :
    SourceUIVersion         : -1
    GeneratingConverterId   : 00000000-0000-0000-0000-000000000000
    SourceFile              :
    Web                     : NCI Intramural Review Site
    ServerRedirected        : False
    IsIRMed                 : False
    IsSharedAccessRequested : False
    EventReceivers          : {}

    Please let me know if you have any suggestions.

    Thanks,

    Rahul


    ASP.NET, C# 4.0, Sharepoint 2007/2010, Infopath 2007/2010 Developer http://sharepoint247.wordpress.com/

    Thursday, August 18, 2016 5:57 PM

Answers

  • Just a thought, I would try to see if you can force checkout the file to yourself via PowerShell. Then, once checked out you could try to check-in the file afterwards. Not sure if it will work but, might. Also, might if not already, see if it was declared as a record if this feature is enable.
    Tuesday, August 23, 2016 2:19 PM

All replies

  • Go to "Document library settings >> Manage files which have no checked in version" take the ownership of the document and then try to check out and check in.

    ---
    Rajesh
    rjesh.com| @rjesh
    You don't need to buy me a beer, if helpful just smile, vote, and mark it as answer.

    Thursday, August 18, 2016 6:08 PM
  • Thanks Rajesh for the quick response.

    Actually I had tried this but the file is not showing up there.

    Thanks,

    Rahul Babar


    ASP.NET, C# 4.0, Sharepoint 2007/2010, Infopath 2007/2010 Developer http://sharepoint247.wordpress.com/

    Thursday, August 18, 2016 6:10 PM
  • Did you try with the SharePoint designer?, try to see whether you are able to check-out or override checkout.

    ---
    Rajesh
    rjesh.com| @rjesh
    You don't need to buy me a beer, if helpful just smile, vote, and mark it as answer.

    Thursday, August 18, 2016 6:21 PM
  • In designer it says the file is checked out for editing by another user (unknown).

    Thanks,

    Rahul


    ASP.NET, C# 4.0, Sharepoint 2007/2010, Infopath 2007/2010 Developer http://sharepoint247.wordpress.com/

    Thursday, August 18, 2016 6:49 PM
  • Hi,

    Please do the following steps

    I recommend:
    Site Actions Site Settings Content and Structure
    / _layouts/Sitemanager.aspx? WebUrl Source = {} _layouts / settings.aspx

    navigate to the library and you can delete documents
    Not appear Check Out

    1- iles from the Microsoft Office 2010 Upload Center from cache,

    2- reset IE (8) settings

    3- delete browsing history

    4- gpupdate /force. 

    Only this option Site Actions > Site Settings > Content and Structure then navigating and deleting the file from the actions menu resulted in the file being deleted.  WEIRD.

    https://social.technet.microsoft.com/Forums/office/en-US/33777698-d680-4499-96f3-91e6c3c035f8/the-file-is-currently-checked-out-or-locked-for-editing-by-another-user-in-document-library?forum=sharepointadmin



    Please remember to click Mark as Answer on the answer if it helps you

    Thursday, August 18, 2016 6:57 PM
  • Thanks Lakshmanan for the response.

    Getting below error.

    The file "https://***/Permissions Old/Current Permissions Summary_20150624.xls" is not checked out.  You must first check out this document before making changes.

    When I click on Actions > Checkout nothing happens and it still shows the same issue.

    Changed library settings to not require checkout before editing; got below error.

    The file "/****/Permissions Old/Current Permissions Summary_20150624.xls" is checked out for editing by .

    This is very strange as the message is not able to get any username in the error message as well

    Thanks,

    Rahul


    ASP.NET, C# 4.0, Sharepoint 2007/2010, Infopath 2007/2010 Developer http://sharepoint247.wordpress.com/

    Thursday, August 18, 2016 7:14 PM
  • Hi Rahul,

    Please try to use SharePoint Manager 2013 to check the file and delete it via right-clicking->Delete:

    You can download SharePoint Manager 2010 from Codeplex:

    http://spm.codeplex.com/

    Note: to use SharePoint Manager 2010, you need to be the farm account.

    Thanks,

    Wendy


    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact tnmff@microsoft.com.

    Friday, August 19, 2016 7:39 AM
    Moderator
  • Wendy,

    Thanks for the response.

    I tried deleting using this tool but unfortunately it is giving same error.

    The file "/****/Permissions Old/Current Permissions Summary_20150624.xls" is checked out for editing by .

    Thanks,

    Rahul Babar


    ASP.NET, C# 4.0, Sharepoint 2007/2010, Infopath 2007/2010 Developer http://sharepoint247.wordpress.com/

    Friday, August 19, 2016 9:07 PM
  • Hi Rahul,

    Can you try with below PS script

    $spWeb = Get-SPWeb http://prinhyltphp0317/
    $libName = "text"
     $lib = $spWeb.Lib |? {$_.Title -eq $lib}
      foreach ($item in $lib.Items)
      {
      $itemFile = $item.File
      if( $itemFile.CheckOutStatus -ne "None" )
      {
          $itemFile.CheckIn("Automatic CheckIn.")
      }
      }
    $spWeb.Dispose()


    Mark it as an answer if it helped you out. Regards Rahul Dagar

    Monday, August 22, 2016 3:09 PM
  • Hi Rahul,

    When your file is get locked it cannot be accessible by Content and Structure Page, Windows Explorer view, SharePoint Designer View and even using SharePoint Designer. You can try to get the user who get locked the file and then you can do other operation.

    We had the same issue and we tried all the way but the below script worked for us, once the script is completed you can try to delete.

    ## Get the user

    $myWeb = Get-SPWeb http://siteURL/project/pmo

    $myFile = $myWeb.GetFile("Shared Documents/PASA KDD log v1 081616.xls")


    $myUserID = $myFile.LockedByUser.ID

    $myUser = $myWeb.AllUsers.GetByID($myUserID)

    ##The following is the all-important piece, open the site as the user who locked the file and then release the lock

    $impSite= New-Object Microsoft.SharePoint.SPSite($myWeb.Url, $myUser.UserToken);

    $impWeb = $impSite.OpenWeb()

    $fileURL = "http://sharepoint.pasa.pas.local/project/pmo/Shared Documents/PASA KDD log v1 081616.xls"

    $impFile = $impweb.GetFile($fileURL)

    $impFile.ReleaseLock($myFile.LockId)


    KRISHANA KUMAR

    SharePoint Architect

    Mosstechnet-kk.com

     

    Please click "Mark As Answer" if this post solves your problem or "Vote As Helpful" if it was useful


    • Edited by KRISHANA KUMAR Monday, August 22, 2016 3:31 PM
    • Proposed as answer by eKnave Tuesday, March 19, 2019 9:52 PM
    Monday, August 22, 2016 3:30 PM
  • Hi Krishna,

    Thanks for the response.

    The script $myFile.LockedByUser is returning null because it is not actually locked.

    Thanks,

    Rahul Babar



    ASP.NET, C# 4.0, Sharepoint 2007/2010, Infopath 2007/2010 Developer http://sharepoint247.wordpress.com/

    Monday, August 22, 2016 5:26 PM
  • One quick solution.

    1) Create folder tempdel inside your document library or where the file is present to be deleted.

    2) Move/Drag and Drop the file to tempdel folder which your planning to delete. 

    3) Delete the tempdel folder. 

    I had a similar problem faced in SP 2007. I followed the above steps. It worked!

    • Proposed as answer by granzoporo Monday, November 4, 2019 3:59 PM
    Tuesday, August 23, 2016 4:24 AM
  • Hi Rahul,

    Did you try to copy or delete the file from Windows explorer view, Go to Document Lib --> Choose Windows Explorer view and try to move file.


    KRISHANA KUMAR

    SharePoint Architect

    Mosstechnet-kk.com

     

    Please click "Mark As Answer" if this post solves your problem or "Vote As Helpful" if it was useful

    Tuesday, August 23, 2016 1:16 PM
  • Thank you Krishna for suggestions.

    I tried to copy that file to another folder but it gives the same issue again.

    Even if I try to delete it from windows explorer; same issue.

    This is one of the strange issues I have faced so far. It says it is locked by some user but properties show no lock, no checkout. Even the error message says locked by user (no username). Username is blank in the error message.

    Thanks,

    Rahul Babar


    ASP.NET, C# 4.0, Sharepoint 2007/2010, Infopath 2007/2010 Developer http://sharepoint247.wordpress.com/

    Tuesday, August 23, 2016 2:07 PM
  • Just a thought, I would try to see if you can force checkout the file to yourself via PowerShell. Then, once checked out you could try to check-in the file afterwards. Not sure if it will work but, might. Also, might if not already, see if it was declared as a record if this feature is enable.
    Tuesday, August 23, 2016 2:19 PM
  • This script worked for me. Thanks!
    Tuesday, March 19, 2019 9:52 PM
  • Hi KRISHANA KUMAR,

    Thanks for your instruction, after reading your explanation, it's seem below character is the solution for this issue, but I'm the new in SharePoint and also encounter the lock of checkout issue, I don't know how to put below character into the SharePoint or it need the software tool to key in, cause I use the website version do not have SharePoint Designer for edit SharePoint, can you tell me how to do it? Thanks!

    $impSite= New-Object Microsoft.SharePoint.SPSite($myWeb.Url, $myUser.UserToken);

    $impWeb = $impSite.OpenWeb()

    $fileURL = "sharepoint.pasa.pas.local/project/pmo/Shared Documents/PASA KDD log v1 081616.xls"

    $impFile = $impweb.GetFile($fileURL)

    $impFile.ReleaseLock($myFile.LockId)

    Regards,

    ilu989

    Thursday, October 17, 2019 2:05 AM