Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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)?
share|improve this question
Why are there many executeQueryAsync's? Can't you just load the last part you need and then call executeQueryAsync once? –  Robert Lindgren Mar 27 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 at 2:07

1 Answer 1

up vote 0 down vote accepted

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
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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