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.

a. Microsoft.SharePoint.dll

b. Microsoft.SharePoint.Taxonomy.dll

  • Add the following namespaces.

a. Using Microsoft.SharePoint;

b. Using Microsoft.Sharepoint.Taxonomy;

  • Replace Program.cs with the following code

  1. using System;

  2. using System.Collections.Generic;

  3. using System.Linq;

  4. using System.Text;

  5. using Microsoft.SharePoint;

  6. using Microsoft.SharePoint.Taxonomy;

  7. namespace SubmissionPolicy

  8. {

  9. class Program   

  10. {

  11. static void Main(string[] args)       

  12. {

  13. using (SPSite site = new SPSite("http://serverName:22222/sites/TestSite/"))           

  14. {

  15. TaxonomySession taxonomySession = new TaxonomySession(site);

  16. TermStore termStore = taxonomySession.TermStores["MMS"];

  17. Group group = termStore.Groups["Submission Policy Test"];

  18. TermSet termSet = group.TermSets["Days of the week"];                

  19. termSet.IsOpenForTermCreation = true;                              

  20. termStore.CommitAll();           

  21. }       

  22. }   

  23. }

  24. }


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.

  1. $taxonomySession=Get-SPTaxonomySession -Site "http://servername:10/"

  2. $termStore=$taxonomySession.TermStores["MMS"] $group=$termStore.Groups["Submission

  3. Policy Test"] $termSet=$group.TermSets["Days of the week"]

  4. $termSet.IsOpenForTermCreation=$true

  5. $termStore.CommitAll()

Recent Posts

See All