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 have this CAML query

var query = new SPQuery{
     Query = string.Format(@"<Where>
          <Or>
                <Or>
                     <Or>
                          <Or>
                                <Contains>
                                     <FieldRef Name='{7}' />
                                     <Value Type='Text'>{3}</Value>
                                </Contains>
                          </Or>
                          <Contains>
                                <FieldRef Name='{6}' />
                                <Value Type='Text'>{2}</Value>
                          </Contains>
                     </Or
                     <Contains>
                          <FieldRef Name='{5}' />
                          <Value Type='Text'>{1}</Value>
                     </Contains>
                </Or>
                <Contains>
                     <FieldRef Name='{4}' />
                     <Value Type='Text'>{0}</Value>
                </Contains>
          </Or>
     </Where>", "title", "adress", "zipcode", "city", "searchTitle", "searchAdress", "searchZipcode", "searchCity")
};

Every time it's ran and I try to use List.GetItems(query); it throws this error:

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

BUT! If I remove all the <Or> tags it works and doesn't throw that error, but I need the <Or> tags to make sure it get all hits.

I've made sure all the fieldrefs matches the internal names of the columns 100%.

share|improve this question
1  
Just to be absolutely sure: you mis-typed the word "address" when you created the columns? –  James Love Aug 15 '11 at 14:17

4 Answers 4

up vote 1 down vote accepted

You specified incorrect column name. Try to use U2U CAML Query Builder. It will build the query based on the internal column names. Is also works with SP2010 even it doesn't specified exactly.

share|improve this answer

Typically this error means that one of the columns you are querying is incorrect. Remember, you must use the Internal column name (an easy way to find the internal column name).

In this specific case, as @JamesLove points out, you have two columns that are misspelled: adress and searchAdress (also, title does not have the correct case).

In addition, you had an extra pair of <Or></Or> nodes.

var query = new SPQuery{
   Query = string.Format(@"<Where>
      <Or>
         <Or>
            <Or>
               <Contains>
                  <FieldRef Name='{7}' />
                  <Value Type='Text'>{3}</Value>
               </Contains>
               <Contains>
                     <FieldRef Name='{6}' />
                     <Value Type='Text'>{2}</Value>
               </Contains>
            </Or
            <Contains>
               <FieldRef Name='{5}' />
               <Value Type='Text'>{1}</Value>
            </Contains>
         </Or>
         <Contains>
            <FieldRef Name='{4}' />
            <Value Type='Text'>{0}</Value>
         </Contains>
      </Or>
   </Where>", 
   "Title", "address", "zipcode", "city", "searchTitle", "searchAddress", "searchZipcode", "searchCity")
};
share|improve this answer

Well, this can also happen when your query is actually not syntactically correct. Extra OR, AND also result into the same error

share|improve this answer

Just to throw a complete alternative into the mix: This error also crops up if you have a column based on a broken or uninstalled Custom Field Type.

A quick look at the List Settings page will show you if this is the case; the troublesome columns will be marked as invalid (with the option to delete them).

share|improve this answer

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.