Description for Taxonomy Term in SharePoint 2010


In this article we will be seeing how about the Description for taxonomy term in SharePoint.

In this article we will be seeing the following:
  • Set the description for a Term
  • Get the description for a Term
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;   
Set the description for a Term:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Taxonomy;
namespace EMM
{
    class Program
    {
        static void Main(string[] args)
        {
            using (SPSite site = new SPSite("http://serverName:10/"))
            {
                TaxonomySession taxonomySession = new TaxonomySession(site);
                TermStore termStore = taxonomySession.TermStores["MMS"];
                Group group = termStore.Groups["SharePoint Group"];               
                TermSet termSet = group.TermSets["Word Automation Term Set"];
                Term term = termSet.Terms["Conversion Settings term"];
                term.SetDescription("Conversion Settings", 1033);           
                termStore.CommitAll();            
            }
        }
    }
}

Taxonomy1.gif

Get the description for a Term:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Taxonomy;
namespace EMM
{
    class Program
    {
        static void Main(string[] args)
        {
            using (SPSite site = new SPSite("http://servcerName:10/"))
            {
                
                TaxonomySession taxonomySession = new TaxonomySession(site);
                TermStore termStore = taxonomySession.TermStores["MMS"];
                Group group = termStore.Groups["SharePoint Group"];               
                TermSet termSet = group.TermSets["Word Automation Term Set"];
                Term term = termSet.Terms["Conversion Settings term"];              
                Console.WriteLine(term.GetDescription().ToString());
                Console.ReadLine();
             }
        }
    }
}

Taxonomy2.gif