• Thanks for the great article. I combined this with some linking to allow users to filter their page based on metadata, check out my project at http://metadatapagefilter.codeplex.com/.

  • Pingback: SharePoint Metadata: Filter Page Web Parts | David Lozzi's Blog()

  • Pingback: Create Search Query with KeywordQuery and Managed Metadata | Lucas Araujo()

  • Antti Laurila

    Hi! I’m not allowed to add webparts in our sharepoint subsite, but the need for this kind of solution is desperate. I tried to combine these scripts together but with very bad results.

    I got the script running – it gave errors and I managed to get rid of them, but still without any results on the page. I created a div with the id: #filter but no results with that either.

    What are the parts that need to be customized in order to make this script running – the site columnname of course, but anything else?

    Great job on the script, this should be a native solution to Sharepoint IMHO.

    • Stefan Bauer

      If you referring to the web part that David Lozzi created you should get in contact with him.
      What you need to change in my script can be found in the function getColor(). There you need to change the following section.

      // Select ‘Color’ Field
      fieldCollection = webSite.get_fields();
      this.colorField = fieldCollection.getByInternalNameOrTitle(“Color”);
      You need to change the name of the field from “Color” to your field name, which has to be a site collection field because otherwise the code slightly change.
      What i have seen in the script is that i referring to the SPServices library which was in my case stored in the _layouts folder. This can be found in the second line of the script.

      needs to be changed to

      This will get SPServices directly from a content distribution network but it could be any place where your SPServices Library is located.
      If you have further trouble you can send me the script and i’ll have to take a look.

  • Antti Laurila

    Hello again and a huge thanks to your super-fast reply. I was referring to the solution on this page and your response gave me enough confirmation to keep on trying to find the solution.

    After some debugging I got the script working. Thanks again for your great script, saves me from doing things twice with Managed Metadata and Custom Lists.

    There were a slight typo in the scripts ‘taxconfig’ variable was referred to as ‘texconfig’ in some places, after these alterations things started to happen!

    • Stefan Bauer

      You are welcome. Thank you for the comment on the typo i need to check it and replace it, when it cause troubles. 😉

  • Joey Jaxson

    Very cool, thanks for posting this. The one thing that I did notice is that the get_schemaXml() is super slow. The data returned for me is over 1 mb and is taking around 7 seconds to return the XML and I only have 25 or so terms. Any idea on ways around that or alternatives that would be more efficient? Thanks again for the post.

    • Stefan Bauer

      get_schemaXml only gets the configuration of the field which will never be more than some bytes of XML data. This also wont contain any term. Would it be possible to see your get_schemaXml result somehow?

  • Joey Jaxson

    You are right it was not the get_schemaXML() it was the
    fieldCollection = webSite.get_fields();
    this.colorField = fieldCollection.getByInternalNameOrTitle(“Color”);

    that was returning 1.2 MB of data which makes sense because that returns every field for the site. I ended up just hard coding the ids of the sspid and the TermSetId which makes it super lightweight and ultra fast.

    Thanks again for the post — Good stuff!

    • Stefan Bauer

      Oh thanks for your comment. I’ll check that but maybe it would work and be for lightweight if you try:

  • I can’t seem to figure out how to cache stuff to prevent the massive amount of ajax queries to Managed Metadata Service. Challenge is that functions are called recursively, so in the completefunc of GetChildTermsInTermSet SPServices call in function GetTermsRecursive function I cannot cache stuff as it is still loading.

    Any thoughts?

    • Stefan Bauer

      Great input. The story behind is that we had a small amount of terms that we had in the term store and are forced to create a SandBox Solution. The problem as you sure know is that you cannot access taxonomy service within a SandBox. In my opinion it depends on the use case how you read the terms. For example if you like to get the terms in a tree view or something link that you can partially load the data from the taxonomy store which doesn’t improve number of ajax requests but improves the loading time. Then you will use the same way as SharePoint does out of the box.
      If you like to get a specific term and all the sub terms it will be much faster to set a specific filter and then recurse through the sub tree.
      If you like to get only terms that currently will be used in your site collection from a specific term set then it’s much faster to query the terms from the TaxonomyHiddenList which exists on root level of every site collection.

  • Eduardo Gonzalez

    Hi Stefan,

    This post is great and complete. But what I don’t understand, is why im not get my taxonomi return, it always says Column doesn’t exist.

    I have almost the same as the first image on my taxonomy term store.. “Taxonomy_bwXML….” instead of “Managed Metadata Store” and Taxonomies instead of “My Taxonomies”, and Color as Color

    what can I do??

    what do you mean with site collection field .. is it the same as the group name in my taxonomy term store??

    Eduardo Gonzalez

  • Eduardo Gonzalez

    Nice Post, everything works just Perfect.

    Thanks for your help

  • Richard Kennedy

    Hi, I realize that this sample was written with SP2010 in mind, (and I’ve used your technique before on that platform.. many thanks!), however I’m now hoping to get this working on SP2013. Unfortunately I’m getting an error: “Microsoft JScript runtime error: Unable to get value of the property ‘TaxonomyField’: object is null or undefined”. I can see my field in the JSON in debug. I’m using jquery-1.8.3 and SPServices-2013.01

    Any ideas?

    • Stefan Bauer

      Sorry haven’t had the time to try if this script still works with SharePoint 2013 or what I need to change to get it running. You might want to take a look at Thorsten Hans blog post about using Taxonomy in SharePoint 2013. You will find it here: http://dnr.azurewebsites.net/2013/02/spscriptlet-3-using-taxonomy/

      Hope I find the time to try it out on SP2013. If so i’ll let you know.

      Greetings Stefan

      • Joe Harthcock

        I just came across this and was able to get it to work pretty much as-is in SP 2013, on-premise. Excellent work!

  • Thanks for a great blog post.

    Using your script but have run into a problem.

    The script is running, but it has a problem if a term is renamed.

    have (from the consol log)

    but now the term has change to P5 and it is not getting the new/renamed name.

    Would have like to see something like

    Any solution/Idea?

    • Stefan Bauer

      This can have something to do with caching. Have you tried to force the Internet Explorer to do a full refresh using SHIFT + Refresh in Browser.

  • Ven

    Can you also, please post how to use GetTermSets method of Taxonomy Web Services from SP Services? I couldn’t find even a single post showing this and I am not able to get it to work. Please help.

    • Stefan Bauer

      Hi Ven, haven’t tried that via SPServices. This will take some time but I am surely looking into. I added it to my TODO list.


  • Hey Stefan, nice post. This was just what I was looking for!

  • Anand Kumar

    Hi Techies,

    I’m facing issues in fieldCollection.getByInternalNameOrTitle(“MyManagedmetadatcolumn”).

    This property works for all other column types in SharePoint 2013 but not with metadata.. Giving me null exception

    Can you please help me out in this issue.


  • Anand Kumar

    I’m getting the following error Unable to get the value of the property : Taxonomy field. Object is null or undefined

    Any references needs to be loaded apart SP.js , i also tried SP.taxonomy.js but its of

    no use.

  • Ankit

    I’m trying to use your approach using SPServices in SP2013 to build an custom global navigation that works across site collections.
    I have terms intended use set to navigation and provided some URLs to them.
    When inside the success callback method of the GetChildTermsRecursive() method I dont see any property inside the xml that contains the URLs that I’ve given to terms.

    How can I retrieve the URLs applied to the term store ?

    • Stefan Bauer

      Actually I just have tested this with SharePoint 2010. In this version there was not really any support for a managed meta data navigation. In SharePoint 2013 this is a lot easier because Microsoft now provides an API for managed meta data. Thorsten Hans give you a brief introduction into the taxonomy in SharePoint 20103. http://dotnet-rocks.com/2013/02/25/spscriptlet-3-using-taxonomy/

  • William

    Hi Stefan, I’m looking for a solution to call term store data via JavaScript, but I noticed that it doesn’t work for ‘anonymous users’, do you have the same problems? any idea about this issue?

    • Stefan Bauer

      Hi William,
      calling term store data with an anonymous user is not supported by SharePoint.
      Sorry there is no way around this.

  • Steve

    Hi I wonder if you can help with the issue I am getting in 0365 SharePoint:

    I have a list in the top level team site containing data, some of which is managed meta data. In any ist level subsite is javascript to access a row in the list above according to the name of the site (there is a corresponding name in the list) and displaying the information in that row in the subsite. This works perfectly at subsite level. However, the subsite also has a list in a similar structure and the subsite of this site uses the same code. This works well for all list column values but does not return managed metadata values. The line of code that works perfectly at subsite level doesn’t work at subsubsite level:


    giving the error:

    Object doesn’t support property or method ‘get_label’

    If I alert oListItem.get_item(‘RAG’) I get object object so it is finding it.

    Its like the code can only get managed metadata if the parent list is in the top level team site.
    Any ideas what could be the issue – I can supply full code if required