Dailycode.info

Short solution for short problems

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

I was trying to order a query on a document library to get all document names ordered in a dropdown. The code looked like this: 

SPList docLib = getDocLib();
 
SPQuery oQuery = new SPQuery();
oQuery.ViewXml = "<View><Query><OrderBy><FieldRef
 Name='Name'/></OrderBy><Where><Gt><FieldRef Name='ID'/>"
 + "<Value Type='Text'>0</Value></Gt></Where></Query></View>";
SPListItemCollection collListItems = docLib.GetItems(oQuery);

 

When I executed the code, I got the error: "One or more field types are not installed properly. Go to the list settings page to delete these fields.". So I first looked around but could not find the correct google words. I had to find it myself. I saved the list as a template, downloaded the stp file and opened it with winzip. The next thing I did was opening the manifest.xml file. I pressed ctrl-f and searched for the string: "FieldRef". Then you will find this in the manifest.xml file:

<ViewFields>
<FieldRef Name="DocIcon"/>
<FieldRef Name="LinkFilename"/>
<FieldRef Name="Modified"/>
<FieldRef Name="Editor"/>
<FieldRef Name="SOPAppro"/>
<FieldRef Name="_Status"/>
<FieldRef Name="SOP_x0020_type"/>
</ViewFields> 

 

I found a field called: LinkFileName.  I decided to use this in the query, and guess what, it worked. The names we see are not always the names SharePoint uses. This is mainly for fields that are defined by SharePoint itself. So my code looks like this now:

SPList docLib = getDocLib();
 
SPQuery oQuery = new SPQuery();
oQuery.ViewXml = "<View><Query><OrderBy><FieldRef
 Name='LinkFilename'/></OrderBy><Where><Gt><FieldRef Name='ID'/>"
 + "<Value Type='Text'>0</Value></Gt></Where></Query></View>";
SPListItemCollection collListItems = docLib.GetItems(oQuery);

 

And it does the trick. So if you are looking for field name in WSS, you can try it this way.