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();
}
});
}
}
}
Comments
Post a Comment