Create termstore using Object model


Create termstore using Object model

public override void ItemAdded(SPItemEventProperties properties)
  {
 base.ItemAdded(properties);
  if (properties.ListTitle == “Projects”)
   {
    if (properties.ListItem.Folder != null)
     {
  string FolderName = properties.ListItem.Folder.Name;
SPSecurity.RunWithElevatedPrivileges(delegate()
   {
using (SPSite osite = new SPSite(properties.SiteId))
  {
 TaxonomySession taxonomySession = new TaxonomySession(osite);
 TermStore store = taxonomySession.TermStores[“Managed Metadata Service”];
            Group group = store.Groups[“Neo Metadata”];
    TermSet productsTermSet = group.TermSets[“Projects”];
      productsTermSet.CreateTerm(FolderName, CultureInfo.CurrentCulture.LCID);
    store.CommitAll();
}
     });
    }
     }
    }
Advertisements

About sharepointsriram

9+ Yrs of IT experience
This entry was posted in Sharepoint 2010 Fast Search. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s