If you get that “famous” error: One or more field types are not installed properly. Go to the list settings page to delete these fields.
you are given absolutely no hint which field and whats wrong with your SPQuery.Query
I’m always using SPBuildInFieldId
with the FieldRef
-statements for out-of-the-box fields so a typo was not the case. But the case was the problem!
var query = new SPQuery(); query.Query = String.Format("<Where><And><Eq><FieldRef Id=\"{0}\" /><Value Type=\"Text\">{1}</Value></Eq></Where>", SPBuiltInFieldId.FileLeafRef, "the-file.name"); |
This code throws the exception. The following code works!
var query = new SPQuery(); query.Query = String.Format("<Where><And><Eq><FieldRef ID=\"{0}\" /><Value Type=\"Text\">{1}</Value></Eq></Where>", SPBuiltInFieldId.FileLeafRef, "the-file.name"); |
The only difference is Id
is now ID
. So in SharePoint Id != ID