I am trying to get the Local Properties for the Navigation Term that is currently being viewed.

For example... If I navigate to http://sp2013/about/team I need to get the Local Custom Properties for the term Team.

Current Solution (performance issues):

  1. Get the Term in the URL window.location.pathname of the current page
  2. Get the default Term Store
  3. Get Group that Term is in
  4. Get Term Set that Term is in
  5. Get Term About (from /about/team)
  6. Get Term Team (from /about/team) and then read Custom Properties.

The performance of this is quite bad because there are so many executeQueryAsync's being called, and the deeper the URL the more queries there will be!!

Other Possible Solutions??

  • Is there a way to just get the Navigation Term that is being viewed on current page with one query?
  • Is there a way to search ALL the Terms in a Term Set a retrieve Term based on Friendly Url (where Friendly Url = window.location.pathname)?
  • Why are there many executeQueryAsync's? Can't you just load the last part you need and then call executeQueryAsync once? Mar 27, 2014 at 7:47
  • @RobertLindgren you just blew my mind! Thanks so much for your direction, all this time I thought I had to first load the object before accessing it, problem solved I will add my updated code. Tnx again!
    – pagemedias
    Apr 1, 2014 at 2:07

2 Answers 2


You could use _spFriendlyUrlPageContextInfo.termId to get the Term information(GUID) for the current page.

  • 1
    Can't find this object, in code or documentation, did you spell it correctly? Could you link the page concerning it? Aug 20, 2014 at 19:56
  • It's not a code object (if it exists) it is a JavaScript object, so it should be available in the dev console of a browser or similar (again, if it exists, I have not double checked ) Aug 20, 2014 at 20:10
  • 1
    as @RobertLindgren mentioned, It is a JavaScript Object and I figured it out using Firebug Console on the Browser. I used it in couple of my CSWP Display Templates to get the Current Page Term(Title, TermID) _spFriendlyUrlPageContextInfo.termId for GUID and _spFriendlyUrlPageContextInfo.title for Term
    – user32668
    Aug 21, 2014 at 14:10
  • If your site uses managed metadata navigation, sharepoint adds this javascript snippet server-side (before page load) in the global namespace. Zero performance hit grabbing the value: var _spFriendlyUrlPageContextInfo = { termId: '3ab1ae31-1f09-4195-b0dd-ecd6b40ca0e3', termSetId: 'd5c96b1b-8bfc-4625-bf11-862a7f296933', termStoreId: 'a6db5754-4226-4c8e-a928-a6c53390a270', title: 'Term Display Name' }; Nov 21, 2014 at 22:04
  • 1
    @hitdrumhard I've tried using this on a site that uses managed metadata navigation and _spFriendlyUrlPageContextInfo returns undefined, what could be the issue?
    – Etheryte
    Jan 26, 2015 at 12:10

Solved the performance issue with the help of Robert as well as came up with an optimised solution by using getTerms() to search the entire Term Store for required Term:

// Get SP Context
var context = SP.ClientContext.get_current();
// Get the default Term Store for context
var session = SP.Taxonomy.TaxonomySession.getTaxonomySession(context);
var termStore = session.getDefaultSiteCollectionTermStore();
// Set up Term Query for termStore.getTerms()
var termQuery = new SP.Taxonomy.LabelMatchInformation(context);
    // The language code identifier (LCID) of the Term.labels to be matched
    // Determines if only terms available for tagging are returned
    // The Label of the Term to get
    termQuery.set_termLabel("My Term");
// Get Terms based on termQuery
var termsStoreTerms = termStore.getTerms(termQuery);
// Load em' and run execute query!
        // Get all the terms based on search
        var termsEnum = termsStoreTerms.getEnumerator();

        // Loop through results
            // Current Item in Enumerator Loop
            var currentTerm = termsEnum.get_current();

            // Get Local Custom Properties
            var termLocalCustomProperties = currentTerm.get_localCustomProperties();
    }, function(sender, args){
        // Failure getting Term
        var error = 'Failure getting Term: ' + args.get_message() + '\n' + args.get_stackTrace

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.