Skip to content

Instantly share code, notes, and snippets.

@princeppy
Forked from vman/sp15tax_newGroup.js
Created July 18, 2018 13:42
Show Gist options
  • Select an option

  • Save princeppy/b8a80c1ac99034f4161e65a9d3beb00f to your computer and use it in GitHub Desktop.

Select an option

Save princeppy/b8a80c1ac99034f4161e65a9d3beb00f 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 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());
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment