The file is not checked out. You must first check out this document before making changes SharePoint 2013 CSOM

This SharePoint 2013 tutorial we will discuss how to solve the file is not checked out. you must first check out this document before making changes. You must first check out this document before making changes error which comes in SharePoint Online/2013/2016 CSOM.

Recently we were working on a SharePoint online site where we needed to upload a few files to a document library. Here we were using SharePoint provider hosted apps or add-in, in that add-in on a button click we were copying those files to the document library.

As we know we can not execute any server-side code inside SharePoint online, we were using .Net managed object model code (csom).

To work with .net managed object model code we need to add below dlls which we can add from NuGet packages.

  • Microsoft.SharePoint.Client.dll
  • Microsoft.SharePoint.Client.Runtime.dll

When we execute code to copy files to SharePoint online document library, we got the below error which says:

The file “https://SiteURL/Document_Library_Name/Archiving16.gif” is not checked out. You must first check out this document before making changes.

The file filename is not checked out sharepoint 2013
SharePoint 2013 The file filename is not checked out

The file is not checked out. You must first check out this document before making changes

One solution is programmatically, you can first check out the file if it already exists and then after finishing the upload you can check-in the file.

But in our case we have checked in the document library, someone mistakenly enables “Create major and minor (draft) versions” in Document Version History of the document library.

So you can go to the Library Settings -> Versioning Settings and in the Versioning Settings page you can disable the Versioning or you can also create major versions like below:

file is not checked out error sharepoint 2013
SharePoint 2013 file is not checked out error

the file is not checked out SharePoint

You may get the file is not checked out error while trying to edit a document in SharePoint Online/2016/2013 document library, if “Require documents to be checked out before they can be edited?” option is enabled in the document library.

To verify if Require Check out is enabled, Open the SharePoint document library, go to the library settings and then click on Versioning Settings.

In the Versioning Settings page, you can see if Require documents to be checked out before they can be edited? is Yes/No.

Make sure, the option should be selected as No, then the file is not checked out SharePoint error will not come.

the file is not checked out sharepoint
the file is not checked out SharePoint

the file is not checked out. you must first check out this document before making changes.

Unable to Check File Out SharePoint

I was also trying to check out the file using csom in SharePoint by using the below code:

using (var ctx = new ClientContext("http://SharePoit Site URL"))
{
var web = ctx.Web;
var file = web.GetFileByServerRelativeUrl("TeamSite/HRDocuments/leavepolicy.pdf");
file.CheckOut();
ctx.ExecuteQuery();
}

But I get error like below:
The file ‘http://SharePoit Site URL/TeamSite/HRDocuments/leavepolicy.pdf’ is not checked out. this case, you need to lead the file first and then you can check out the file.

using (var ctx = new ClientContext(_sitename))
{
var web = ctx.Web;
var file = web.GetFileByServerRelativeUrl(serverRelativeUrl);
ctx.Load(file);
file.CheckOut();
ctx.ExecuteQuery();
}

the file is not checked out you must first check out this document

If you are getting the same issue “the file is not checked out you must first check out this document“, Check if the document is currently locked by any user? Or any other use is already check out the file.

Read some SharePoint 2013 csom tutorials:

Now the file is not checked out. you must first check out this document before making changes. You must first check out this document before making changes issue will not come. Hope this will be helpful.

>