I am trying to deploy a multi-select taxonomy field using the PnP provisioning engine 1.5.915.0 and the termsetid token in the XML. If the term group and/or the term store have a space in the name (e.g. "Document Types") I get an error from the engine:
"Exception has been thrown by the target of an invocation"
And I see this error in the ULS logs:
"Exception occured in scope Microsoft.SharePoint.SPFieldCollection._SerializeToJson. Exception=System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.FormatException: Expected hex 0x in '{0}'.
at System.Guid.GuidResult.SetFailure(ParseFailureKind failure, String failureMessageID, Object failureMessageFormatArgument)
at System.Guid.TryParseGuidWithHexPrefix(String guidString, GuidResult& result)
at System.Guid.TryParseGuid(String g, GuidStyles flags, GuidResult& result)
at System.Guid..ctor(String g)
at Microsoft.SharePoint.Taxonomy.TaxonomyField.ParseGuidFromCustomProperty(Object obj)
at Microsoft.SharePoint.Taxonomy.TaxonomyField.SetProperties()
at Microsoft.SharePoint.Taxonomy.TaxonomyField.Initialize(SPFieldCollection fields)
at Microsoft.SharePoint.Taxonomy.TaxonomyField..ctor(SPFieldCollection fields, String fieldName) -
-- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark)
at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at System.Activator.CreateInstance(Type type, Object[] args)
at Microsoft.SharePoint.SPFieldCollection.CreateSPFieldFromSafeArray(Int32 index)
at Microsoft.SharePoint.SPFieldCollection.EnsureSPField(Int32 index)
at Microsoft.SharePoint.SPFieldCollection.ItemAtIndex(Int32 iIndex)
at Microsoft.SharePoint.Client.ServerStub.d__36.MoveNext()
at Microsoft.SharePoint.Client.ServerStub.WriteChildItems(JsonWriter writer, Object obj, ClientObjectQuery objectQuery, ProxyContext proxyContext)
at Microsoft.SharePoint.Client.ServerStub.WriteAsJson(JsonWriter writer, Object obj, ClientObjectQuery objectQuery, ProxyContext proxyContext)
at Microsoft.SharePoint.Client.ServerStub.WriteAsJsonWithMonitoredScope(JsonWriter writer, Object value, ClientObjectQuery objectQuery, ProxyContext proxyContext)"
If I go into CA and edit both the term group and store to remove the space and update the XML accordingly then the code works fine. The site collection where the site column is being added being created as part of the provisioning process so its a fresh site. What's interesting is if I get the above error no matter what I do to correct the XML file the error persists. If I delete the site collection and correct the XML then everything works.
Is there some way to escape/encode the space character so that I can use spaces in the metadata service? This is the field's definition in the provisioning XML.
<pnp:SiteFields>
<Field Type="TaxonomyFieldTypeMulti" DisplayName="Document Type" ShowField="Term1033" Required="FALSE" EnforceUniqueValues="FALSE" Mult="TRUE" Sortable="FALSE" Group="My Custom Columns" ID="{871b859d-0ad8-4159-b0c7-a7fba53744a8}" StaticName="DocumentType" Name="DocumentType">
<Default>
</Default>
<Customization>
<ArrayOfProperty>
<Property>
<Name>SspId</Name>
<Value xmlns:q1="http://www.w3.org/2001/XMLSchema" p4:type="q1:string" xmlns:p4="http://www.w3.org/2001/XMLSchema-instance" p4:schemaLocation="">{sitecollectiontermstoreid}</Value>
</Property>
<Property>
<Name>GroupId</Name>
</Property>
<Property>
<Name>TermSetId</Name>
<Value xmlns:q2="http://www.w3.org/2001/XMLSchema" p4:type="q2:string" xmlns:p4="http://www.w3.org/2001/XMLSchema-instance">{termsetid:CustomMetadata:DocumentTypes}</Value>
</Property>
<Property>
<Name>AnchorId</Name>
<Value xmlns:q3="http://www.w3.org/2001/XMLSchema" p4:type="q3:string" xmlns:p4="http://www.w3.org/2001/XMLSchema-instance">00000000-0000-0000-0000-000000000000</Value>
</Property>
<Property>
<Name>UserCreated</Name>
<Value xmlns:q4="http://www.w3.org/2001/XMLSchema" p4:type="q4:boolean" xmlns:p4="http://www.w3.org/2001/XMLSchema-instance">false</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">false</Value>
</Property>
<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">{[A GUID]}</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>
<Property>
<Name>IsKeyword</Name>
<Value xmlns:q8="http://www.w3.org/2001/XMLSchema" p4:type="q8:boolean" xmlns:p4="http://www.w3.org/2001/XMLSchema-instance">false</Value>
</Property>
<Property>
<Name>TargetTemplate</Name>
</Property>
<Property>
<Name>CreateValuesInEditForm</Name>
<Value xmlns:q9="http://www.w3.org/2001/XMLSchema" p4:type="q9:boolean" xmlns:p4="http://www.w3.org/2001/XMLSchema-instance">false</Value>
</Property>
<Property>
<Name>FilterAssemblyStrongName</Name>
<Value xmlns:q10="http://www.w3.org/2001/XMLSchema" p4:type="q10:string" xmlns:p4="http://www.w3.org/2001/XMLSchema-instance">Microsoft.SharePoint.Taxonomy, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Value>
</Property>
<Property>
<Name>FilterClassName</Name>
<Value xmlns:q11="http://www.w3.org/2001/XMLSchema" p4:type="q11:string" xmlns:p4="http://www.w3.org/2001/XMLSchema-instance">Microsoft.SharePoint.Taxonomy.TaxonomyField</Value>
</Property>
<Property>
<Name>FilterMethodName</Name>
<Value xmlns:q12="http://www.w3.org/2001/XMLSchema" p4:type="q12:string" xmlns:p4="http://www.w3.org/2001/XMLSchema-instance">GetFilteringHtml</Value>
</Property>
<Property>
<Name>FilterJavascriptProperty</Name>
<Value xmlns:q13="http://www.w3.org/2001/XMLSchema" p4:type="q13:string" xmlns:p4="http://www.w3.org/2001/XMLSchema-instance">FilteringJavascript</Value>
</Property>
</ArrayOfProperty>
</Customization>
</Field>
</pnp:SiteFields>