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(); } } } } 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(); } } } }
You need to be a premium member to use this feature. To access it, you'll have to upgrade your membership.
Become a sharper developer and jumpstart your career.
$0
$
. 00
monthly
For Basic members:
$20
For Premium members:
$45
For Elite members: