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?
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.