SharePoint 2013 Hosting News: How to Create Term Store Manipulation Using C# Code in SharePoint 2013?
In this article, I will show you How to create New Group, TermSet, Term. Add term to TemSet and in turn to the Group. Now, write the following code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Microsoft.SharePoint; using Microsoft.SharePoint.Taxonomy; namespace TestTermStore { class Program { static void Main(string[] args) { using (SPSite site = new SPSite("http://sharepoint")) { //instantiate a new session to a site TaxonomySession sesssion = new TaxonomySession(site); //Get the term store TermStore NauticalStore = sesssion.TermStores["Managed Metadata Service"]; //Create a new term group Group Working = NauticalStore.CreateGroup("Working Sailing"); //Create a new term set TermSet termSetClasses = Working.CreateTermSet("Class Types"); //Add terms Term term1 = termSetClasses.CreateTerm("A", 1033); Term term2 = termSetClasses.CreateTerm("B", 1033); Term term3 = termSetClasses.CreateTerm("C", 1033); Term term4 = termSetClasses.CreateTerm("D", 1033); Term term5 = termSetClasses.CreateTerm("E", 1033); Term term6 = termSetClasses.CreateTerm("F", 1033); Term term7 = termSetClasses.CreateTerm("G", 1033); //Commit changes to the store NauticalStore.CommitAll(); //Delte a term term1.Delete(); //set descriptions and labels term2.SetDescription("Learning", 1033); term2.CreateLabel("B", 1033, false); NauticalStore.CommitAll(); Console.WriteLine("Group Added"); Console.ReadLine(); } } } } |
Best SharePoint 2013 Hosting Recommendation HostForLIFE.eu HostForLIFE.eu offer the Best, Cheap and Recommended SharePoint 2013 hosting start from €9.99/month. They can load your site against anticipated traffic and recommend the best option for you. HostForLIFE.eu is Microsoft No #1 Recommended Windows and ASP.NET Hosting in European Continent. Their service is…