In this article we will be seeing how to create a new taxonomy group for a term store in SharePoint 2010 using API.

In this article we will be seeing the following:

Steps Involved:

Create a new group in a term store:

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.CreateGroup("SharePoint Group");
termStore.CommitAll();
}
}
}
}


taxonomy1.gif

Get all the groups of a particular term store:

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"];
GroupCollection groupColl = termStore.Groups;
foreach (Group group in groupColl)
{
Console.WriteLine(group.Name);
Console.WriteLine(group.Id);
}
Console.ReadLine();
}
}
}
}

taxonomy2.gif