Managed Metadata Fields in Office 365/SP Online Sandbox Solution

Hi,

Developing Metadata fields is always a complicated case of the developers. My previous posts(Add Metadata Taxonomy Custom Field using Visual Studio) I explained how we can create metadata site columns. In this  post, I will target Office 365/SP online users who can only use sandbox solutions to update/create metadata fields.

Reason why treditional solutions does not with Office 365

In practical scenario, Metadata service details like SSPID, Default term store etc keep on changing. I notice that the name of Metadata service of SharePoint Online keeps on updating after some updates. We all know that code in sandboxed solutions is being deprecated by Microsoft. But even if we were happy to use sandboxed code - in Office 365/SharePoint Online, we cannot use the Microsoft.SharePoint.Taxonomy namespace in server-side code anyway – the net result is that we are unable to “finish the job” in this way to ensure the field is correctly bound to the Term Store. This is a problem! Even worse, whilst it is possible in the CSOM API to bind the field, having this execute in the provisioning process (e.g. as a site is being created from the template) is challenging, maybe impossible. Maybe you could come up with some imaginative hack, but that’s probably what it would be.

Solution:

If I talk about the solutions of this issue, then our thoughts might lands on setting the metadata field manually. But again its very tedious for clients to do such configuration for 500/1000 sites. There could be one alternative which can save our life if we can figure out the SSPID and Termset Id for particular environment . Following is the code for creating custom fields if you want to map the columns with particular Term set provided you must be aware of two of the required Ids.
<Field ID="{9e9022b8-19e7-41da-8dc2-ced13a5e94a9}" StaticName="CustomField" Name="CustomField" Description="A field provisioned with static Term Store config values." DisplayName="Custom Field" Type="TaxonomyFieldTypeMulti" Required="TRUE" ShowField="Term1033" EnforceUniqueValues="FALSE" DisplaceOnUpgrade="TRUE" Mult="TRUE" Group="Custom Columns" Overwrite="TRUE">

<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">16af1375-f30a-4f9d-88c6-1a92ad3778b8</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">2cd1c0fb-88af-4066-a4fc-4c9734160eb5</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">{81afcd4b-fdf2-44f4-a0e6-0ea32ebb78c8}</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">true</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>


NOTE:

Make sure you replace SSPID and TermSet ID with your metadata store IDs.


Happy SharePointing :)

Comments

Popular posts from this blog

Hide Ribbon on SharePoint 2013 using CSS

Get Comment Count in SharePoint

Configure external site as content sources in sharepoint search