Field with name "Wiki_x0020_Page_x0020_Categories" was not found

Jul 20, 2010 at 2:45 PM
I'm trying to add the Managed Metadata WebPart on a Web Part Page. I want the WebPart to point to a List of Enterprise Wiki pages and display their Wiki Categories Metadata values. On the WebPart I have the following options set: WebURL: /Corporate/KnowledgeBase ListName: Pages FieldName: Wiki_x0020_Page_x0020_Categories When trying to display the WebPart I get the error 'Field with name "Wiki_x0020_Page_x0020_Categories" was not found' I'm sure this is the correct field name because if I enter "bogus" or "reallybogus" as the field name I get a different error: One or more field types are not installed properly. Go to the list settings page to delete these fields. Ideas?
Aug 26, 2010 at 2:31 PM
Edited Aug 26, 2010 at 2:33 PM

To answer my own question, the problem is code.  When it attempts to get a reference to the metaDataField, the Fields array is not indexed by the internal name but the display name.  So the code will work if your internal field name is the same as the display name.  In my case a Wiki Page list the Wiki Categories field's internal name is Wiki_x0020_Page_x0020_Categories.

I change the line of code from


TaxonomyField metaDataField = (TaxonomyField)myList.Fields[_FieldName];




TaxonomyField metaDataField = (TaxonomyField)myList.Fields.GetField(_FieldName);


The GetField method will work with both an internal name or a display name and thus fixes the problem.

Thanks for the code sample!

Dec 9, 2010 at 11:23 AM

cmerrill - thank you so much for posting your fix!!! Helped me out a lot.

Jun 29, 2011 at 6:54 PM

Hi! I tried this and it did resolve my issue........the list is displaying properly.  However the item counts are all at 0.  Is there somewhere else in the code that needs to be updated? Thanks!