2

I want to determine the checkout status of a document using the Client Side Object Model rather than the Server Object Model.

Does anyone know how to do this? Or even whether it's possible?

Can it be determined from the SharePoint SQL Server?

Thanks.

0

How to verify check-out status for a file in a document library using CSOM

Assume the following method for retrieving a file

private static ListItem GetListItem(string url, ICredentials creds, string listTitle,int listItemId)
{
     using (var clientContext = new ClientContext(url))
     {
                clientContext.Credentials = creds;

                var list = clientContext.Web.Lists.GetByTitle(listTitle);
                var listItem = list.GetItemById(listItemId);
                clientContext.Load(list);
                clientContext.Load(listItem,i => i.File);
                clientContext.ExecuteQuery();
                return listItem;
      }
}

then to verify checkout state of a file (CheckOutType)

var listItem = GetListItem("https://contoso.sharepoint.com", credentials, "Documents", 1);
 var file = listItem.File;
 if (file.CheckOutType !=  CheckOutType.None)
 {
        //file was checked out
 }  

How to verify check-out status (SPFile.SPCheckOutStatus) for a file in a document library using SSOM

SPFile file = item.File;
if (file.CheckOutStatus != SPFile.SPCheckOutStatus.None)
{
    //file was checked out
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.