private Term GetTermFromAfterProperties(SPItemEventProperties properties)
{
TaxonomySession termSession =
new TaxonomySession(properties.ListItem.Web.Site);
new TaxonomySession(properties.ListItem.Web.Site);
TermStore termStore = termSession.TermStores[0];
Group group =
termStore.Groups.Cast<Group>().First(g => g.Name.Equals("GroupName"));
termStore.Groups.Cast<Group>().First(g => g.Name.Equals("GroupName"));
TermSet termSet =
group.TermSets.Cast<TermSet>().First(t => t.Name.Equals("TermSetName"));
group.TermSets.Cast<TermSet>().First(t => t.Name.Equals("TermSetName"));
int value = (Int32)properties.AfterProperties["interalFieldName"];
// Yes it's an Int, but if you're saving from an office application
// like MS Word it's a string number like "23"
// Yes it's an Int, but if you're saving from an office application
// like MS Word it's a string number like "23"
SPField field = properties.ListItem.Fields["fieldDisplayName"];
TaxonomyFieldValue tfv = new
TaxonomyFieldValue(value.ToString(), field);
Guid termGuid = new
Guid(tfv.TermGuid);
Term term = termSet.GetTerm(termGuid);
return term;
}