Monday, April 30, 2007

One of more field types are not installed properly

Another FAQ that I see a lot from developers - they get the error "One of more field types are not installed properly" in their applications.
No, don't blame your database in being corrupt, and don't go beat up the guy who create the list and the fields. The problem is simple:
You'r code is doing a CAML query, and uses a field name that does not exist.

I hear you say "but I checked my CAML query, and the field names are correct", and I have to remind you - field names in CAML queries should be internal names, not display names.
This is why, if you have a field called "Parent Task" (for example), in CAML you should refer to it as "Parent_x0020_Task", because the internal name is encoded to avoid special characters.
Also, the internal name may be totaly different from the display name - this will happen if you created a field and then renamed it. So the internal name remains the same as the old name, but the display name changed.
Another scenario for this is when you created your own list definition, and specified different internal and display names. (this happened to me recently)

So, how to know what is the internal name for your field? simple - just click on it!
Let me elaborate - create a view in the list that has that field, and click on the field to sort the list by it. In the web address (url) of the page you are directed to, the internal name of the field should be displayed, after the query string "SortField=".
If the field does not allow sorting, you can go to the list settings and click on the field, as if you want to change it's settings. Again, the internal name of the field will be in the URL address of the page.
Please note, that the field names in the URLs are encoded again, and you will have to compensate for that. for example, a field with a space like "Parent Task" will not be displayed like I said before in the address bar as "Parent_x0020_Task", but instead as "Parent%5fx0020%5fTask" (the underscore character was replaced by the unicode equivalent "%5f").

So you want an easier way to find the internal name (without coding)?
Just do yourself a huge favour and download U2U CAML Builder which is a terrific application to help you build CAML queries.
Since the tool knows it has to use internal names, it just does it for you!.
I cannot live without this tool
U2U CAML Builder screen


Andrew Woodward said...

Ishai, Amazing how working on the SharePoint Nested Tasks project we get to see the same errors :)


Anonymous said...

Ishai.. you just saved my day (and it isn't the first time)
Great Post!!

James Tsai

Anonymous said...

Here's the most useful resources you'll ever find: A Table listing all the internal field names and their corresponding display names!

Xixi said...

I got this error message because someone deleted the Category column from the post list. Now, when I click on the individual post, it gives me this error. When I opened "New," and view the source code, I couldn't find this category because it was already deleted by that person. Now, what should I do? I can't delete the Categories list either.

Anonymous said...

Hi Ishai (and all reading this) - here is the quick and easy way of finding the internal name. Fomr the UI, just edit the column ({List} > Settings > Click on the {Column} to edit it). Now just look at the "?Field={internal name}" part of the query string. Done!!