Created
December 19, 2012 10:46
-
-
Save vman/4335879 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(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. | |
var termStore = termStores.getByName("Taxonomy_Dmxzz8tIBzk8wNVKQpJ+xA=="); | |
//Term Set under which to create the term. | |
var termSet = termStore.getTermSet("b49f64b3-4722-4336-9a5c-56c326b344d4"); | |
//Name of the term, LCID and a new GUID for the term. | |
var newTerm = termSet.createTerm("India", 1033, "b49f64b3-4722-4336-9a5c-56c326b344a9"); | |
//newTerm.set_isAvailableForTagging(true); | |
context.load(newTerm); | |
context.executeQueryAsync(function(){ | |
alert("Term Created: " + newTerm.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