SharePoint 2010: Values entered in Enterprise Keywords column are not saved for Office 2007 and 2010

Symptoms

Create a site column which has two words and a space between these two words through Object Model code. Associate this site column and "Enterprise Keywords" column to a Site Content type. Associate this Content type to a Document library. Upload a 2007 document to the document library and enter values for the Enterprise Keywords column and click Ok. Edit properties of the document and notice that the Enterprise Keywords value is not saved. Values are stored for txt or Office 2003 file types.

Cause

When we create a site column through the Object model and associate the StaticName property of the field with a string which has two words and a space between these two words and set this field as Required you would notice this issue.

Resolution

While assigning the StaticName property of the field ensure that the string doesn't have any spaces between the words.

For Ex: Issue would occur if we create a Site column as given below

SPSite oSite = new SPSite("<SiteURL>");
SPWeb oWeb = oSite.OpenWeb();
oWeb.AllowUnsafeUpdates = true;
SPFieldText retTypeText = new SPFieldText(oWeb.Fields, SPFieldType.Text.ToString(), "Test Column");
objNewField = retTypeText;
if (objNewField != null)
{
objNewField.Title = "Test Column";
objNewField.Required = true;
objNewField.ShowInDisplayForm = true;
objNewField.ShowInEditForm = true;
objNewField.ShowInNewForm = true;
objNewField.ShowInViewForms = true;
objNewField.ShowInListSettings = true;
objNewField.StaticName = "Test Column";
oWeb.Fields.Add(objNewField);
oWeb.Update();
}
oWeb.AllowUnsafeUpdates = false;
oWeb.Dispose();
oSite.Dispose();

To resolve the issue, in above code ensure that the value for ObjNewField.StaticName is set as "TestColumn" instead of "Test Column"

Microsoft Internal Support Information

Steps to reproduce.

Product Bug Number:
Author ID (email alias):pavank
Tech Review ID (email alias):spskbpre, ctrshrpt
Confirm Article has been Tech Reviewed: Yes
Confirm Article released for Publishing: Yes
Properties

Article ID: 2430626 - Last Review: Oct 25, 2010 - Revision: 1

Feedback