Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

How do you programmatically enable Enterprise Keywords for a SharePoint 2010 list?

This is how you do it using the GUI:

Enterprise Keywords enabler

Igor Philippov has a solution which uses reflection and adds the field to the items in the library but doesn't fully work - it doesn't show the Enterprise Keywords field when viewing/editing properties, and it doesn't check this checkbox. I'm not sure why, since it seems to do the exact same thing as the code-behind for the checkbox in the GUI (in Microsoft.SharePoint.Taxonomy.OM.CodeBehind.MetadataColSettings.OkButton_Click).

Specifically, when enabling Enterprise Keywords via the GUI, it seems that the Enterprise Keywords field is added to all the list's content types, but when doing it programmatically this way, the field is only added to the default content type.

Another solution is to simply add the Enterprise Keywords column to the list, but that has exactly the same drawbacks, right?

share|improve this question
add comment

2 Answers 2

The key here is to know the secret number, i.e. the Guid of the Keyword Metadata field, which is:

23F27201-BEE3-471e-B2E7-B64FD8B7CA38

For collectors, here is a list of SharePoint 2010 Guids.

Then I think you can solve the problem, e.g.:

<FieldRef ID="{23f27201-bee3-471e-b2e7-b64fd8b7ca38}" Name="TaxKeyword" />

I think to do it programmatically you would do something like:

SPField field = this.m_list.ParentWeb.AvailableFields[guid];
list.Fields.Add(field);

Disclaimer: I haven't tested this, sorry.

share|improve this answer
add comment

You can even add enterprise keywords column to your list using reflection. See my question here on sharepointoverflow.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.