2

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>

3 Answers 3

2

Found the answer: remove the space from the group or term set name in the XML. You can leave the spaces in the metadata fields themselves.

5
  • Weird. Facing the same issue. Would it find the proper group then?
    – Akhoy
    Dec 21, 2017 at 10:42
  • IIRC once I removed the spaces like I said above everything worked. I don't remember specifically if the groups work and I can no longer check, but I am pretty sure they did I would have mentioned it. Dec 22, 2017 at 16:46
  • Did you by any chance export the term store as well? I'm only exporting the fields and not the term store. For me the issue I think is, that it's not replacing the placeholder values.
    – Akhoy
    Dec 23, 2017 at 7:57
  • I don't think so but don't remember for sure. This project was for defining a site template we were reusing a lot so I don't think I would be exporting the term sets as well. Maybe when I did the initial template generation I used the export tool but subsequent changes to the template would have been iterative (i.o.w. we would have modified the XML by hand as needed). Sorry I can't be more help. :S Dec 24, 2017 at 15:46
  • I had the same error when provisioning metadata navigation. When I took the spaces out of my termset name and updated the template, it worked.
    – Lance
    Jan 13, 2021 at 22:48
0

Have you found any way to recover your site collection after you have broken it with this invalid field-xml? We are experiencing ourselves that we unrecoverably break the site column collection as soon as we apply this invalid field-xml. We don't know of a way to recover only to drop the site collection and to recreate it again which of course is not a scalable solution for many production sites. This poses a big risk in letting power users define their own field-xml to apply. Have you followed up with Microsoft product management?

1
  • In my case removing the space character from the term set name in the XML solved my issue. Looking at the stack trace you might be able to use the x0020 space name escaping for the term set name, but that is supposition. Jun 2, 2016 at 14:12
0

Changing id from uppercase to normal resolved the problem

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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