SharePoint 2013: Creating Managed Metadata Columns that allow Fill-In Choices
This is a relatively quick post. There’s a fair bunch of stuff written about creating columns in SharePoint 2013 that use Managed Metadata termsets. However, some of it is a pain to find and then some. I have had to deal with two frustrating issues lately, both of which boil down to poor sharepoint documentation.
Wictor Wilén wrote the post I point people at for most stuff on managed metadata columns, but this time the internet couldn’t help.
First of all, I wanted to create a custom column which used a termset to hold data. This is well documented. However, I wanted to allow fill-in choices and could I make that work? My termset was open, my xml column definition looked right, but no fill-in choice. Update the column via the web UI and I could turn fill-in on and off with no problem. In the end, I examined the column with PowerShell before and after the change. It turns out (and this is not the only place they do it) the UI stays the same, but the settings changed in the background are different. For metadata columns the FillInChoice property is ignored – you must add a custom property called Open:
1<?xml version="1.0" encoding="utf-8"?> <Elements xmlns="http://schemas.microsoft.com/sharepoint/"> <Field ID="{b7406e8e-47aa-40ac-a061-5188422a58d6}" Name="FeatureGroup" DisplayName="Feature Group" Type="TaxonomyFieldType" Required="FALSE" Group="Nimbus" ShowField="Term1033" ShowInEditForm="TRUE" ShowInNewForm="TRUE" FillInChoice="TRUE"> <Customization> <ArrayOfProperty> <Property> <Name>TextField</Name>; <Value xmlns:q6="http://www.w3.org/2001/XMLSchema" p4:type="q6:string" xmlns:p4="http://www.w3.org/2001/XMLSchema-instance">{b7406e8e-47aa-40ac-a061-5188422a58d6}</Value> </Property> <Property> <Name>Open</Name> <Value xmlns:q5="http://www.w3.org/2001/XMLSchema" p4:type="q5:boolean" xmlns:p4="http://www.w3.org/2001/XMLSchema-instance">true</Value> </Property> <Property> <Name>IsPathRendered</Name> <Value xmlns:q7="http://www.w3.org/2001/XMLSchema" p4:type="q7:boolean" xmlns:p4="http://www.w3.org/2001/XMLSchema-instance">false</Value> </Property> </ArrayOfProperty> </Customization> </Field> <Field Type="Note" DisplayName="FeatureGroupTaxHTField0" StaticName="FeatureGroupTaxHTField0" Name="FeatureGroupTaxHTField0" Group="Nimbus" ID="{164B63F0-3424-4A9B-B6E4-5EC675EF5C75}" Hidden="TRUE" DisplaceOnUpgrade="TRUE"> </Field> </Elements>
Whilst we’re on the subject, if you want metadata fields to be correctly indexed by search, the hidden field MUST follow the strict naming convention of
When using the content by search web part, what gets indexed by search is the text of the term in the column within the content type. However, if you enter a search query wanting to match the value of the current page or item what gets pushed into the search column is the ID of the term (a GUID), not the text. It is possible to match the GUID against a different search managed property, but that only gets created if you name your hidden field correctly. Hat-tip to Martin Hatch for that one, in an obscure forum post I have not been able to find since.