JG Vimalan's Blog

It is all about coding!

SPException – One or more field types are not installed properly. Go to the…

Sharepoint developers often face the following exception while querying a custom list or document library using SPQuery.


for example, I’ve got this exception in the following code snippet,

string lname = memberLeaveAccount[“LoginName”].ToString();

if (string.IsNullOrEmpty(lname))

int chrIndex = lname.IndexOf(“#”);

if (chrIndex >= 0)
   lname = lname.Substring(chrIndex + 1);

SPQuery spQuery = new SPQuery();
spQuery.Query = “<Where><Eq><FieldRef Name=’Account‘></FieldRef> <Value Type=’Text’>” + lname + “</Value></Eq></Where>”;
SPListItemCollection EmployeeRecord = MyCustomList.GetItems(spQuery);

string gender = string.Empty;

//If an employee record is removed from custom list, just move to next record.
if (EmployeeRecord == null)

//Strong check
if (EmployeeRecord != null && EmployeeRecord.Count == 0)

I’ve got the exception at ‘EmployeeRecord.Count’. I’ve found that, the field name ‘Account’ is only the Display Name and the internal name is “AccountName”. So, after giving the correct internal name, the SPQuery worked fine.

NOTE: To get the fields (in custom list or document library) Internal Name, 

foreach(SPField field in MyCustomList.Fields)



October 10, 2009 - Posted by | SharePoint

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: