I am trying to search some pages from "Site Pages" Library. Here is my sample code

string q= @"<Where>
                           <FieldRef Name='Name' Ascending='False' />
                           <Value Type='Text'>Home</Value>
  SPQuery query = new SPQuery { Query = q, RowLimit = 1 };      
  SPListItemCollection items = list.GetItems(query);

On executing the above code I get the following error.

"One or more field types are not installed properly. Go to the list settings page to delete these fields."


I think that 'Name' is just the display name for the field you want to query. You probably need to use the internal name for the field, which is probably something like 'LinkFileName' or 'Title'

  • How can i find the internal name? – V.B Jul 25 '12 at 12:15
  • 2
    With powershell/Microsoft SharePoint Snap-In: $w = get-spweb <webUrl>; $l = $w.Lists["yourlist"]; $f = $l.Fields.GetField("Name"); $f.InternalName. This will give "FileLeafRef". – Matthias Jul 25 '12 at 12:46

You probably have to reference the "Name" field in the ViewFields of the SPQuery object:

query.ViewFields = "<FieldRef Name='Name' />";
  • Thanks for replying but this doesn't work. What I see is there are other columns named as "Name" for "Site Pages" Library.This could be the problem may be. – V.B Jul 25 '12 at 11:45

If you go into the list settings for the list you are trying to query, and hover over the column (in this case 'Name'), you should be able to see the field type for that column.

For example, for the Name column in a SharePoint list, you might see the following:


So you'd use

<FieldRef Name='Title'> 

in your query for that list.

  • For some reason "Name" column is not listed in the list of columns for "Site Pages" – V.B Jul 26 '12 at 5:01

Atlast I resolved the problem by using internal name for the column "Name" as "FileLeafRef".

Thanks all for your suggestions.

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.