1

I'm using SharePoint 2010 and I want to get the files that are not either checked out nor checked in. Meaning that I want to retrieve all documents that: - were uploaded in the Documents library without pressing Save button and without doing any change on them further more (either check out or check in) - were added in the document library using Windows Explorer option

I've tried to use the following CAML Query:

<Query><Where><IsNull><FieldRef Name="CheckoutUser" /></IsNull></Where></Query>

But the above query returns the desired documents + the documents that have been check-in. I want to display just the first category.

The other method I've tried was to loop over the files of the library and to check the following condition:

file.CheckOutType == SPFile.SPCheckOutType.None

But also the above condition returned the same results as the CAML Query.

Is there a reliable method to programmatically distinguish between simply uploaded documents and check-in documents in SharePoint 2010?

EXTRA INFORMATION:

Below are the steps to reproduce the issue:

STEP 1: Ensure that option "Require documents to be checked out before they can be edited?" under Library Settings>Versioning settings is set to ¨No¨ STEP 2: In the document library, click ¨Add document¨. Select the document and click OK. STEP 3: Another window appears with the file name and other data and with a Save and Cancel buttons. Click Cancel button. STEP 4: The file is now uploaded but it is not checkout nor checked-in. At this step it has a single version. STEP 5: Try to upload a document with the same name following the procedure described above. Make sure option "Add as a new version to existing files" is checked. STEP 6: The file is updated with a new version but its status is neither checkout nor checked-in. I want to retrieve only these files that have an uncertain status (they are simply uploaded). These can be documents that users uploaded but forget to checkout or check-in. If the "Require documents to be checked out before they can be edited?" option is set to True then SPDocumentLibrary.CheckedOutFiles will return the newly uploaded files. But the problem is, when this option is set to False, then SPDocumentLibrary.CheckedOutFiles does not return anything.

If anyone can help with this issue please give a reply.

0

Every checked in document would have more than one versions while a simply uploaded documents would only have one version. You can work upon this concept, I'll try to add some code snippet to support my answer in just a mean while!

  • If I modify the same document (without modifying its name) and I upload it again using option "Add as a new version to existing files", then the document will have multiple versions. So, it is possible for a simply uploaded document to have multiple versions and in that case the version condition is not enough to separate between the two document types. – MSPDev Nov 19 '15 at 13:35
  • Can you be more elaborate regarding what is the difference between 2 documents you are trying to differ? – Taran Goel Nov 19 '15 at 17:42
  • Please see the update under EXTRA INFORMATION section. – MSPDev Nov 20 '15 at 8:22
0

If you do not need to use a caml query and you can get the SPList object this property will return documents that have been uploaded but not checked in. It will not include all checked out documents, just the ones who do not have an initial checkin.

SPDocumentLibrary.CheckedOutFiles

  • If the document library has the option "Require documents to be checked out before they can be edited?" set to True then the SPDocumentLibrary.CheckedOutFiles will retrieve the newly uploaded documents. But if the above option is set to False then the SPDocumentLibrary.CheckedOutFiles will not return anything. I need a solution for the case when "Require documents to be checked out before they can be edited?" is set to False. – MSPDev Nov 19 '15 at 15:56

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.