Friday 6 December 2013

“One or more field types are not installed properly. Go to the list settings page to delete these fields.” On Sharepoint 2010 or 2013

When you use SPQuery you could get this message. This is probably because the INTERNAL name of the field is different than the display name.

Having this code with this field “Unit Id” (Internal name “UnitId”) we could get the error because we are referring the name with a space.

Incorrect:

 string camlQuery = @"<Where>                                    
                        <Eq>
                           <FieldRef Name='Unit Id' />
                           <Value Type='Text'>" + UnitID + @"</Value>
                        </Eq>                                      
                      </Where>";

Correct:
 string camlQuery = @"<Where>                                    
                        <Eq>
                           <FieldRef Name='UnitId' />
                           <Value Type='Text'>" + UnitID + @"</Value>
                        </Eq>                                      
                      </Where>";