Resolving "File Checked Out Or Locked For Editing" Issue In SharePoint

Problem

The file is currently checked out or locked for editing by another user in SharePoint

About the Problem

Hello geeks, sometimes it becomes a little tricky to delete a folder in the SharePoint library.

In this particular article, we’re going to see such a scenario in which a user has full rights to the library but is unable to delete the folder in SharePoint 2013 or SharePoint Online.

Click on ok

Or in the modern view, it’s something like.

Folder

Let’s start the journey.

In SharePoint, a user having full permission on the library, even if he/she is a site collection admin, is unable to delete items just because that item is checked out by another user. But, what if he is unable to figure out by whom the item is checked out? So, here, we come to the problem with a good solution.

Let’s understand it by a scenario here.

A user created a library named Library1 and created a folder named Folder1.

Create document library

Now, create a folder in Library1 named Folder1.

Create a folder

Now, the user has created a document in a document library.

Note. The tricky part comes into the picture now. By default, when a user creates a Library, it comes with versioning enabled. Somehow suppose that versioning is not enabled or manually disabled by the user at the time of creation, then the versions of the item will not be captured.

Sometimes, what happens is that when a user creates a document, it directly goes into the checked-out state without having the version enabled in the list. So now, the document is in a checked-out state and doesn’t have a check-in version as the version was not enabled. This is called "Files with no checked-in version".

So, let's dig deeper into the problem and find the solution.

A user uploaded a document in Folder1 (created above).

Library

Now, let's check its version history.

Version history

So, we understand that versioning is enabled on the list. Now, the user checked out the document for editing purposes. Another user is still able to see the document in the checked-out state just because it has a version.

Checked out

Let’s see another aspect of this scenario. Suppose versioning is disabled from the settings page of the list/library.

Library

Also, the user enabled one more setting for checking out the document.

Require check out

What is this setting all about? When a user creates a document, it directly goes into the checked-out state without having any changes which means the user is now authorized to make changes before anyone else makes a change.

If you look in the ECB menu, the option related to versioning is not shown.

Now, the user uploads a new document and that document is directly checked out as required, and the setting is enabled at the library level.

Library level

Now, let’s see when another user looks into the library.

Library

Note. The first user who created the document checks in the ImportTermSet.csv file.

Wow, another user can’t see a newly created document that was checked out at the time of creation by the first user (Asha in this case).

So when another user wants to delete Folde1, he/she gets the error.

Item delete

Something went

So now, think about how a user identifies which document is checked out by which user so that he can delete the unused folder.

So here is the solution. There is a setting on the setting page.

Manage file

Click on the setting above. The user can see how many documents in Libray1 are checked out that have no checked-in version. So, in this case, the user can do two things to delete that folder. One, he can ask the person to check out to release the document, or second, he can take ownership of that document.

So in rare cases, suppose a user takes ownership of that document that is checked out by someone else.

Files checked

Now, the user can see both documents.

Both document

Now, the user can discard check-out or check-in.

User csv

Now if the user wants to delete the folder he can successfully delete that folder.

Note. For security reasons, it is not acceptable that someone else delete our file. This is only acceptable when folders have some garbage files that have no meaning at all.

So here is the final output of the problem.

Delete

Progress

Now the folder has been deleted. This is also applicable when we try to delete the folder using custom code (JSOM, CSOM, SSOM, REST API, PowerShell).

Thanks for reading.

Please comment for a healthy knowledgeable conversation.