SPList.GetItems error – One or more field types are not installed properly

This article is to address one of the very common errors in SPList which most of the SharePoint developer face while working with SPList object. Let me try to explain the scenario first and the error.
Let’s say we have a list name Registration which when submitted some kind of action item need to execute. Say, we are considering asynchronous event for this SPListItem and we are trying to execute some query i.e. SPQuery for the ItemUpdated() asynchronous event. So the basic approach is once list item will be updated, we need to fires some query against that list to validate. Simple like execute SQL with Where clause.
SQL query in this system is to validate whether the list item has any filed value i.e. RefID which has the value 4. Very simple SQL Statement and it is something like Select count(RefID) From ListTable where RefID=4.

Following the very basic SPQuery approach while implementing, following the CAML integration with SPQuery where _ReferList is the SPList object.

int RefIDCount = 0;

SPQuery _SPQuery = new SPQuery();

_SPQuery.Query = “<Where><Eq><FieldRef Name=RefID”/><Value Type=’Number’>4</Value></Eq></Where>”;

RowCount = _SPList.GetItems(_SPQuery).Count;

Got any error while debugging at the GetItems line and the error is “One or more field types are not installed properly. Go to the list settings page to delete these fields.”. Something  strange, because nothing I have changed in the SharePoint list so fart. In other words no column or filed is being updated/added or deleted after creating the list.
While debugging, I lookinto the following XML value:
Xml    “<z:row xmlns:z=’#RowsetSchema’ ows_ContentTypeId=’0x01001154DBA4728B9D4F93F2F592B12B647800940D3EA946D79647859EB2CA15CC8D54′ ows_RefID=’3.00000000000000′ ows_Waybil_x0023_=’1003′ ows_FormType=’ChargesForm’ ows_PatientName=’Jim Baals’ ows_MRN_x0023_=’4567′ ows_FormStatus=’Pending’ ows_ContentType=’ChargesForm’ ows_ID=’3′ ows_Modified=’2009-12-10 18:14:10′ ows_Created=’2009-12-10 18:14:10′ ows_Author=’1;#MOSS\\Administrator’ ows_Editor=’1;#MOSS\\Administrator’ ows_owshiddenversion=’1′ ows_WorkflowVersion=’1′ ows__UIVersion=’512′ ows__UIVersionString=’1.0′ ows_Attachments=’0′ ows__ModerationStatus=’0′ ows_SelectTitle=’3′ ows_Order=’300.000000000000′ ows_GUID=’{4446D8FA-AF69-4791-88BC-AE4A19375558}’ ows_FileRef=’3;#region/apac/india/Lists/MedicalDataEntry/3_.000′ ows_FileDirRef=’3;#region/apac/india/Lists/MedicalDataEntry’ ows_Last_x0020_Modified=’3;#2009-12-10 18:14:10′ ows_Created_x0020_Date=’3;#2009-12-10 18:14:10′ ows_FSObjType=’3;#0′ ows_PermMask=’0x7fffffffffffffff’ ows_FileLeafRef=’3;#3_.000′ ows_UniqueId=’3;#{37EA51B3-9229-4B77-A0F9-C2B14AB55663}’ ows_ProgId=’3;#’ ows_ScopeId=’3;#{28695DDC-FC34-48CD-9D42-13C4F2A6151D}’ ows__EditMenuTableStart=’3_.000′ ows__EditMenuTableEnd=’3′ ows_LinkFilenameNoMenu=’3_.000′ ows_LinkFilename=’3_.000′ ows_ServerUrl=’/region/apac/india/Lists/MedicalDataEntry/3_.000′ ows_EncodedAbsUrl=’http://moss:29688/region/apac/india/Lists/MedicalDataEntry/3_.000′ ows_BaseName=’3_’ ows_MetaInfo=’3;#’ ows__Level=’1′ ows__IsCurrentVersion=’1′ ows_ServerRedirected=’0′/>\r\n”    string

The first thing is struck in my mind is filed Internal name. I found in the XML, many filed name is address with internal name i.e. name starts with ows_… So, I go ahead and edit the Query a little bit dynamic:

int RefIDCount = 0;

SPQuery _SPQuery = new SPQuery();

_SPQuery.Query = “<Where><Eq><FieldRef Name=’” + _SPList.Fields[“RefID”].InternalName + “‘/>” + “<Value Type=’” + _SPList.Fields["RefID"].FieldValueType.ToString() + “‘>4</Value></Eq></Where>”;

RowCount = _ReferList.GetItems(_SPQuery).Count;

And finally this works for me. Hope this post will you to debug quickly :)

  1. January 21st, 2011 at 13:57

    I like it extremely considerably! Just extraordinary! Your composition manner is pleasing and the way you dealt the topic with grace is notable. I’m intrigued, I make bold you are an professional on this topic. I am signing up for the incoming updates from now on.

You must be logged in to post a comment.