How to add a Term to Term Store Object model SharePoint 2010
Add following reference to the solution
using
System.Globalization;
using
Microsoft.SharePoint;
using
Microsoft.SharePoint.Taxonomy;
To add term in the term store, add following code
SPSite site = new SPSite("http://newdemo2010"); TaxonomySession taxSession = new TaxonomySession(site); TermStore termStore = taxSession.TermStores["Managed Metadata Service"]; Group storeGroup = termStore.Groups["BPTemplate"]; TermSet termSet = storeGroup.TermSets["Timecard"]; termSet.CreateTerm(pTerm, 1033); //It will term to the root term Term propertyIdsTerm = termSet.Terms["TimeLog"]; propertyIdsTerm.CreateTerm(pTerm, CultureInfo.CurrentCulture.LCID); //This will add term to a termtermStore.CommitAll();
|
0 comments:
Post a Comment