In this post I will describe how to fix the following error:
Exception message: Failed to get value of the "Enterprise Keywords" column from the "Managed Metadata" field type control. See details in log. Exception message: Invalid field name. {1390a86a-23da-45f0-8efe-ef36edadfb39}
Microsoft.SharePoint.WebControls.BaseFieldControl.OnLoad(EventArgs e)
Microsoft.SharePoint.Taxonomy.TaxonomyFieldControl.OnLoad(EventArgs e)
System.Web.UI.Control.LoadRecursive()
…System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
You may face with it e.g. when edit publishing page. It says that there is no field with Id = {1390a86a-23da-45f0-8efe-ef36edadfb39} in the underlying content type. This field is hidden Note field TaxKeywordTaxHTField which is supplementary field for OTB Enterprise Keywords managed metadata field (Id = {23f27201-bee3-471e-b2e7-b64fd8b7ca38}). There are 2 ways which you can use for fixing the problem:
1. Check the underlying content type of the page which you create/edit. It should contain both fields: TaxKeywordTaxHTField and TaxKeyword. If it contains only TaxKeyword, you will encounter with the problem above. I wrote about this solution here: Add Enterprise keywords field into custom content type.
2. Go to the doclib settings (Pages > Settings) and go to Permissions and Management > Enterprise Metadata and Keywords Settings:
And then ensure that checkbox “Add an Enterprise Keywords column to this list and enable Keyword synchronization” is checked:
Once you enable it, it won’t be possible to disable it from UI (checkbox will be checked and disabled).
Also it is possible to enable it programmatically. If you will check codebehind of the application layouts page “Enterprise Metadata and Keywords Settings” (metadatacolsettings.aspx), you will find that it uses internal class MetadataListFieldSettings. In order to enable it programmatically we have to use reflection:
1: var assembly = Assembly.LoadWithPartialName("Microsoft.SharePoint.Taxonomy");
2:
3: var type = taxonomy.GetType("Microsoft.SharePoint.Taxonomy.MetadataListFieldSettings");
4: object settings = type.GetConstructor(new Type[] { typeof(SPList) })
5: .Invoke(new object[] { list });
6: type.GetProperty("EnableKeywordsField", BindingFlags.NonPublic | BindingFlags.Instance)
7: .SetValue(settings, true, null);
8: type.GetProperty("EnableMetadataPromotion", BindingFlags.NonPublic | BindingFlags.Instance)
9: .SetValue(settings, true, null);
10: type.GetMethod("Update", BindingFlags.NonPublic | BindingFlags.Instance)
11: .Invoke(settings, null);
12:
13: type.GetMethod("KeywordsFieldExistsInContentTypes", BindingFlags.NonPublic | BindingFlags.Instance)
14: .Invoke(settings, new object[] { true });
15: type.GetMethod("Update", BindingFlags.NonPublic | BindingFlags.Instance)
16: .Invoke(settings, null);
After performing one of these two steps, error should disappear.
No comments:
Post a Comment