Skip to content

Instantly share code, notes, and snippets.

@vman
Created December 19, 2012 11:29
Show Gist options
  • Select an option

  • Save vman/4336064 to your computer and use it in GitHub Desktop.

Select an option

Save vman/4336064 to your computer and use it in GitHub Desktop.
$(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 Term Set.
var termStore = termStores.getByName("Taxonomy_Dmxzz8tIBzk8wNVKQpJ+xA==");
//Get group by GUID
var peopleGroup = termStore.getGroup("97eaa7b8-9778-4f61-acb3-7f47abba13c3");
//Create New Term Set in Group with Name, New GUID and LCID
var newTermSet = peopleGroup.createTermSet("New TermSet Name","49dac247-d315-4065-8718-e8c3f50e7dcd",1033);
context.load(newTermSet);
context.executeQueryAsync(function(){
console.log(newTermSet.get_name());
},function(sender,args){
console.log(args.get_message());
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment