SharePoint 2013: View Checked Out Documents

Recently a client using SharePoint 2013 asked me if there was a good way to view their checked out documents in one of their document libraries. I of course remembered from SharePoint 2010 that in list settings there was a ‘Manage Checked out Files’. So, I went to get the link for them only to find that this has been replaced with a page that only shows documents that have been added, but have not bee checked in for the first time. So now lacking an out of the box solution I delved into some CAML code to see if I couldn’t just create a custom view to recreate this.

So before we jump into the code, let me list the requirements for this view.

  • First, we need to see documents checked out to any user. This is simple enough because there is a Checked out user field in the library with the fieldname of ‘CheckoutUser’.
  • Second, the users have been using folders in their libraries. Lots of folders nested within folders so we need to make it recursive. Simple enough we just add the scope tag to the view node Scope=”RecursiveAll”.
    • I tried doing this with the <QueryOptions><ViewAttributes> setup but it wouldn’t work for me until I added the scope attribute directly to the view node.
  • And last but not least we need to think about what information to display in the view. The Document type, a link to it, the user who currently has the file checked out, and lastly since the users like their folders we should include the folder path of the file.

So fire up SharePoint designer, log into your site and locate your library. From there create a new view, then open it for editing. In the XML/HTML of the view code locate the <XmlDefinition> node. By default it will probably be one long line. I always prefer to format it with proper indentation to make sure I have things in the right areas, but your code should look something like similar to this.

<XmlDefinition>
	<View Scope="RecursiveAll" ... >
		<Query>
			<Where>
				<IsNotNull>
					<FieldRef Name="CheckoutUser" />
				</IsNotNull>
			</Where>
			<OrderBy>
				<FieldRef Name="FileLeafRef"/>
			</OrderBy>
		</Query>

	   	<ViewFields>
			<FieldRef Name="DocIcon"/>
			<FieldRef Name="LinkFilename"/>
			<FieldRef Name="CheckoutUser"/>
			<FieldRef Name="FileDirRef" />
		</ViewFields>
		<!-- Other built in nodes will be here -->
	</View>
</XmlDefinition>

 

Note that there will be a lot of other data in the opening <View> node that we don’t want to touch. Also there will be some other option nodes after the <ViewFields> node that we can ignore.

Save your view and go look at the results in a browser. If done right, we should now have a view that will show all the documents checked out. Simple enough and while we have to change the caml xml, no true code updates or installs required.

 

Leave a Reply

Your email address will not be published. Required fields are marked *