Skip to content

Instantly share code, notes, and snippets.

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

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

Select an option

Save princeppy/293133a9be028f994824f09f81523b48 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(){
var context = SP.ClientContext.get_current();
var list = context.get_web().get_lists().getByTitle('TaxonomyCustomList');
var listItem = list.getItemById(1);
context.load(listItem);
context.executeQueryAsync(function(){
//Multivalue Taxonomy Column
var taxEnumerator = listItem.get_item("MyTaxColumn").getEnumerator();
while(taxEnumerator.moveNext()){
//Label
var currentTerm = taxEnumerator.get_current();
//Label
var label = currentTerm.get_label();
//Term GUID
var termGUID = currentTerm.get_termGuid();
//Type ID
var typeID = currentTerm.get_typeId();
//WSS ID
var wssID = currentTerm.get_wssId();
}
},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