Sharepoint Online JSOM API Taxonomy bug - renamed term returns old value

Pierre 21 Reputation points


I would like to share what I think is a SPO bug.

I use JSOM to get all terms in the TermSet. As I don't want to hard-code any specific ID, I search for a termset by name:

    var termSetListFuncArea = termStore.getTermSetsByName(termSetFunctionalAreaName, 1033);    
    var termSetFuncArea = termSetListFuncArea.getByName(termSetFunctionalAreaName);    
    var termsFuncArea = termSetFuncArea.getAllTerms();

    context.load(termsFuncArea, 'Include( Labels, IsDeprecated, Name )');

It worked well until I renamed one of my terms. Although the taxonomyhidden list and all document metadata were up to date with the new name, getting the default label was always returning the old value. Even when I completely removed the old labels, and only kept the new one.

Finally, without changing the executeQueryAsync code, I made it work by using ID for getting the TermSet:

  var termSetFuncArea = termStore.getTermSet("3f71a246-965c-4f3b-bf4e-4a858237c3a9");
    var termsFuncArea = termSetFuncArea.getAllTerms();
    context.load(termsFuncArea, 'Include( Labels, IsDeprecated, Name )');

Now I get the new, renamed label. But what a pain!

Of course I only have one TermSet with this name.

A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
8,614 questions
SharePoint Server Development
SharePoint Server Development
SharePoint Server: A family of Microsoft on-premises document management and storage systems.Development: The process of researching, productizing, and refining new or existing technologies.
1,543 questions
0 comments No comments
{count} votes

Accepted answer
  1. Amos Wu-MSFT 4,051 Reputation points

    I could not reproduce your issue.
    My test result:49828-test67.gif
    My test code for your reference:

        $(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 taxSession = SP.Taxonomy.TaxonomySession.getTaxonomySession(context);  
          var termStores = taxSession.get_termStores();  
          var termStore = termStores.getByName("Taxonomy_hAIlyuIrZSNizRU+uUbanA==");  
          var termSet = termStore.getTermSetsByName("test",1033);  
          var terms = termSet.getByName("test").getAllTerms();  
          context.executeQueryAsync(function () {  
            var termEnumerator = terms.getEnumerator();  
            var termList = "Terms: \n";  
            while (termEnumerator.moveNext()) {  
              var currentTerm = termEnumerator.get_current();  
              termList += currentTerm.get_name() + "\n";  
          }, function (sender, args) {  

    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

0 additional answers

Sort by: Most helpful