Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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

string q= @"<Where>
                        <Eq>
                           <FieldRef Name='Name' Ascending='False' />
                           <Value Type='Text'>Home</Value>
                        </Eq>
                     </Where>";
  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."

share|improve this question
add comment

4 Answers

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'

share|improve this answer
    
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
add comment

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

query.ViewFields = "<FieldRef Name='Name' />";
share|improve this answer
    
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
add comment

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:

https://yoursharepointsite/_layouts/FldEdit.aspx?List=%7B80CABC04%2D5AB5%2D4595%2DA265%2DDC50272F8BA8%7D&Field=Title

So you'd use

<FieldRef Name='Title'> 

in your query for that list.

share|improve this answer
    
For some reason "Name" column is not listed in the list of columns for "Site Pages" –  V.B Jul 26 '12 at 5:01
add comment
up vote 0 down vote accepted

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

Thanks all for your suggestions.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.