0

I want to know how to programmatically create a TermGroup which is accessible and usable through all SiteCollection.

0

As state here. I used it and it worked for me!

 $(document).ready(function(){   

        var scriptbase = _spPageContextInfo.webServerRelativeUrl + "_layouts/15/";

        $.getScript(scriptbase + "SP.Runtime.js",
            function () {
                $.getScript(scriptbase + "SP.js", function(){

                    $.getScript(scriptbase + "SP.Taxonomy.js", execOperation);

                });
            }
        );

    });

    function execOperation(){

        //Current Context
        var context = SP.ClientContext.get_current();

        //Current Taxonomy Session
        var taxSession = SP.Taxonomy.TaxonomySession.getTaxonomySession(context);

        //Term Stores
        var termStores = taxSession.get_termStores();

        //Term Store under which to create the group.
        var termStore = termStores.getByName("Taxonomy_Dmxzz8tIBzk8wNVKQpJ+xA==");      

        //New Group with name and new GUID
        var newGroup = termStore.createGroup("New Group Name","b300304a-1693-4629-a1c0-dff7bda644ff");

        context.load(newGroup);

        context.executeQueryAsync(function(){

        console.log(newGroup.get_name());

        },function(sender,args){

        console.log(args.get_message());

        });

    }

For c# see here. I did not test it!

  • Thanks, but you always have to reference a SiteCollection. Is there a way to leave this off? When you go to the Central Administration an then the to the TermStore, there is no need to reference a SiteCollection. And this is my question: how to do this in code (C#) without referencing a SiteCollection? – BOG Sep 5 '15 at 7:24
  • Has noone did this before? Or am i wrong with my requirements? – BOG Sep 6 '15 at 11:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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