Tag Archives: sharepoint libraries

NEUGS Part 1: Welcome to the SharePoint Jungle

Before I came to SoftArtisans, I’d never heard of SharePoint. (You can gasp here or save it for later in the post.) As is my wont, I began using it without ever reading any documentation or general how-it-works-for-essentially-tech-illiterate-fools-type information. Which, in terms of doing most of what I need to do (uploading docs to libraries and writing blog posts on my My Site), is not the worst strategy, but it left a lot of gaps. So, with Ben’s encouragement, I recently began a comprehensive SharePoint-for-the-End-User curriculum. And, to my surprise and chagrin, found that there really isn’t one. Don’t get me wrong, End User SharePoint is an amazing resource—but I’d say it’s more tailored to post-bacs. Microsoft used to have a series of training videos, but they seem to be down at the moment, and their getting started articles are pretty skimpy early on and fragmented after the ABCs. So, like any great innovator (if you’ve been holding in that gasp, you can let it out now), I decided to create my own guide. Welcome to part one of many: What SharePoint does for me and which of its parts I will use. Continue reading NEUGS Part 1: Welcome to the SharePoint Jungle

Searching for Files with CAML

I was interested in searching for a file in a Document Library. Using a CAML query is much more efficient than iterating through the Document Library and examining each file. There are a couple of scenarios.

Searching at the root level of the Document Library

Searching for files is a little different from searching for other list items. In SharePoint, a file is shown with the same attributes as any other list item. When creating the CAML query, it would seem natural to search a field such as Title for a given file name. However, for a document, the Title field by default doesn’t store the file name. Rather, it contains arbitrary content that can be edited in Word (under the document’s Properties).

Furthermore, when creating the CAML query, you must reference a field using its internal name. So you won’t be able to use a field such as “Name”, as it is not a valid internal name (source: List of internal names for SharePoint fields).

Incorrect internal name error
If you don’t use the correct internal name of a field in a query, you may get the following error when attempting to access the results of the query: One or more field types are not installed properly. Go to the list settings page to delete these fields.

The correct field to use when searching for files is FileLeafRef, which is the appropriate internal name to use for the Name field. The C# snippet to create the query is as follows: Continue reading Searching for Files with CAML