In Site Design how to associate metadata term with site column?

Copper Contributor

Hello,

 

I am using site design {Schema documentation} to create new sites. Expecting new sites created from site design will have site columns, Content types and Lists. I able to provision column, content type and list but facing issue with site column type "TaxonomyFieldTypeMulti".

 

I would like to associate column with existing Term in my tenant. In On premise we can do this association on feature activation but in office 365 we have limitations. Please suggest code or alternative. 

code is as below :

 

1st Attempt [tried PnP site template style]--

{
"verb": "createSiteColumnXml",
"schemaXml": "<Field ID=\"{4EDAD5E3-AAAB-48AA-8F7B-2A70ECA14652}\" StaticName=\"Engine\" Name=\"Engine\" DisplayName=\"Engine\" Type=\"TaxonomyFieldTypeMulti\" Group=\"Mygrp\"><TaxonomyGroup ID=\"a8674c62-e812-4e23-88fc-a449958e53ea\">Cars</TaxonomyGroup><TermSet ID=\"d92adc9e-eba7-4734-ac56-ae82483bf1c0\">Engine</TermSet></Field>"
}

 

2nd Attempt --

{
"verb": "createSiteColumnXml",
"schemaXml": "<Field ID=\"{4EDAD5E3-AAAB-48AA-8F7B-2A70ECA14652}\" ShowField=\"Term1033\" StaticName=\"Engine\" Name=\"Engine\" DisplayName=\"Engine\" Type=\"TaxonomyFieldType\" Group=\"Mygrp\"></Field>"
}

 

3rd Attempt --

{
"verb": "createSiteColumnXml",
"schemaXml": "<Field ID=\"{4EDAD5E3-AAAB-48AA-8F7B-2A70ECA14652}\" ShowField=\"Engine1033\" StaticName=\"Engine\" Name=\"Engine\" DisplayName=\"Engine\" Type=\"TaxonomyFieldType\" Group=\"Mygrp\"></Field>"
}

 

 Terms are below : 

 

TenantTerm.png

 

Reference : #2470 on Github 

 

1 Reply

I managed to add a site column using the script below: - 

{
"actions": [
{
"verb": "createSiteColumnXml",
"schemaXml": "<Field Type=\"Note\" DisplayName=\"{FieldName}_0\" StaticName=\"{StaticName}\" SourceID=\"http:\/\/schemas.microsoft.com\/sharepoint\/v3\" Name=\"{StaticName}\" ID=\"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX\" ShowInViewForms=\"FALSE\" Required=\"FALSE\" Hidden=\"TRUE\" CanToggleHidden=\"TRUE\" />"
},
{
"verb": "createSiteColumnXml",
"schemaXml": "<Field Type=\"TaxonomyFieldType\" Name=\"{Fieldname}\" SourceID=\"http:\/\/schemas.microsoft.com\/sharepoint\/v3\" StaticName=\"{FieldName}\" DisplayName=\"ArticleType\" Group=\"Custom Columns\" ShowField=\"Term1033\" Required=\"FALSE\" EnforceUniqueValues=\"FALSE\" Mult=\"TRUE\"> <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\">YYYYYYYY-YYYY-YYYY-YYYY-YYYYYYYYYYYY</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\">ZZZZZZZZ-ZZZZ-ZZZZ-ZZZZ-ZZZZZZZZZZZZ</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\">00000000-0000-0000-0000-000000000000</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>TextField</Name><Value xmlns:q6=\"http://www.w3.org/2001/XMLSchema\" p4:type=\"q6:string\" xmlns:p4=\"http://www.w3.org/2001/XMLSchema-instance\">XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX</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>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> </ArrayOfProperty> </Customization> </Field>"
}
}
The XXXX - GUID was for the new field and the YYYY and ZZZZ guids need to come from the term store. However, it was ultimately a waste of time because the search didn't work against the new fields that I created so ended up using using the PnP script below 

Connect-PnPOnline "https://{tennancy}.sharepoint.com/sites/{sitename}" -UseWebLogin

 

Add-PnPTaxonomyField -DisplayName "ArticleType" -InternalName "{fieldname}" -TermSetPath "{termset}|{terms}"   -Group "Custom Columns" -MultiValue

 

Add-pnpfield  -field ArticleType -List SitePages


I'm still waiting for this functionality to be added to site designs - something that @Sean Squires suggested would be coming on twitter - so that I can do it properly with site designs.