2

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

4

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
1

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
1

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.

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

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.