We have a cross-site publishing setup with a managed navigation from terms that the items are marked with. On the item pages I have the term or terms that a given item is marked with. I have both their names and their GUIDs, but I imagine the GUIDs will be more direct.
For example I have a document that is marked with both Mobile and Tools terms and I have the following GUIDs for this item:
GP0|#0c422db8-7973-44e5-b35a-c46cf1b7aa49;
L0|#00c422db8-7973-44e5-b35a-c46cf1b7aa49|Learning team tools and process;
GTSet|#0a31782c-ceb0-459f-b625-d98753c26922;
GPP|#8a7d2039-55e5-4b65-99bb-354bc53a9d1e;
GP0|#bf624af6-190a-4047-b3bf-238c8a60e8d7;
L0|#0bf624af6-190a-4047-b3bf-238c8a60e8d7|Mobile-accessible learning
The ones that start with GP0 are the ones I am interested in finding the friendly urls for.
I'm finding a few tutorials on how to work with the term store in C# like this one but I need to do this client side with javascript and I'm not sure how to translate C# into the corresponding javascript api.
Does anyone know how to get the friendly url for a term given the guid? Thanks.
Edit: Code to get the term
I've found this code to retrieve the term from the GUID.
var scriptbase = _spPageContextInfo.webAbsoluteUrl+"/_layouts/15";
$.getScript(scriptbase +"/sp.runtime.js",function(){
$.getScript(scriptbase + "/sp.js", function() {
$.getScript(scriptbase + "/sp.publishing.js",function(){
$.getScript(scriptbase+"/sp.taxonomy.js",function(){
getTermByGuid('974f8fd6-99f5-49f2-a5ee-cdf536f5cfcb');
})
})
})
})
function getTermByGuid(guid){
var ctx = SP.ClientContext.get_current();
var web = ctx.get_web();
var tax = SP.Taxonomy.TaxonomySession.getTaxonomySession(ctx);
var term = tax.getTerm(guid);
ctx.load(tax);
ctx.load(term);
ctx.executeQueryAsync(function(){
console.log(term);
})
}
The Term has all kinds of info in it, but nothing for the friendly url -- at least that I can find. I don't know if it is there and I just can't figure out how to get it or if I need to make a request to include it.
Also I've found some other examples that reference SP.Publishing.Navigation.TaxonomyNavigation.getTermSetForWeb but not in terms of jsom, only C#.