Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have created managed metadata Group named "MyGroup" in term store (Managed Metadata Service) programmatically under FeatureActivated method in sharepoint 2013 as below:

     public override void FeatureActivated(SPFeatureReceiverProperties properties)
        {

        Guid fieldID1 = new Guid("{e7344bac-ce09-4254-96eb-387aa0635bd4}");
        SPSite site = properties.Feature.Parent as SPSite;
        TaxonomySession session = new TaxonomySession(site);
        var termStore = session.TermStores["Managed Metadata Service"]; 

            var group = termStore.CreateGroup("MyGroup");
            SPField field1 = site.RootWeb.Fields[fieldID1];
            var termSet1 = group.CreateTermSet(field1.InternalName);
    // Connect to MMS
  TaxonomyField taxonomyField1 = site.RootWeb.Fields[fieldID1] as TaxonomyField;
     taxonomyField1.SspId = termSet1.TermStore.Id;
                            taxonomyField1.TermSetId = termSet1.Id;
                            taxonomyField1.TargetTemplate = string.Empty;
                            taxonomyField1.AnchorId = Guid.Empty;
                            taxonomyField1.Update();
        }

Code successfully executed but I don't see "MyGroup" under site settings->Term store management. Why its not there ?

share|improve this question

1 Answer 1

up vote 0 down vote accepted

I think you are missing the CommitAll() after you make the changes to the termstore.

...
var termSet1 = group.CreateTermSet(field1.InternalName);
termStore.CommitAll();
...

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.taxonomy.termstore.commitall.aspx

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.