Submission Policy for term set in SharePoint 2010:Part 2


Introduction:

Organization governance can allow the end users to add the terms to the term store. In the term set settings there is an option called "Submission policy" which is used to allow the end users to add the terms to the term set. The end users can add the terms to the term sets in the metadata column dialog box. In this article we will be seeing how to enable this option to add the terms to the term set by the end user using SharePoint object model and powershell. In part 1 I have explained how to set the submission policy through UI.

Using SharePoint object model:

Steps Involved:

  • Open visual studio 2010.
  • Create a new console application.
  • Add the following references.

    • Microsoft.SharePoint.dll
    • Microsoft.SharePoint.Taxonomy.dll
     
  • Add the following namespaces.

    • Using Microsoft.SharePoint;
    • Using Microsoft.Sharepoint.Taxonomy;
     
  • Replace Program.cs with the following code

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Microsoft.SharePoint;
    using Microsoft.SharePoint.Taxonomy;

    namespace SubmissionPolicy
    {
        class Program
        {
            static void Main(string[] args)
            {
                using (SPSite site = new SPSite("http://serverName:22222/sites/TestSite/"))
                {
                    TaxonomySession taxonomySession = new TaxonomySession(site);
                    TermStore termStore = taxonomySession.TermStores["MMS"];
                    Group group = termStore.Groups["Submission Policy Test"];
                    TermSet termSet = group.TermSets["Days of the week"];
                    termSet.IsOpenForTermCreation = true;              
                    termStore.CommitAll();
                }
            }
        }
    }

Using powershell:

Steps involved:

  • Go to Start => All Programs => Microsoft SharePoint 2010 products => SharePoint 2010 Management Shell.
  • Run as an administrator.
  • Run the following script.

    $taxonomySession=Get-SPTaxonomySession -Site "http://servername:10/"
    $termStore=$taxonomySession.TermStores["MMS"] $group=$termStore.Groups["Submission Policy Test"] $termSet=$group.TermSets["Days of the week"]
    $termSet.IsOpenForTermCreation=$true
    $termStore.CommitAll()