0

I have created the term group and term set in SharePoint 2013.i have loaded the term set retrieve query after loading the files are sp.js, sp.taxonomy.js, sp.publishing.js.The termset retrieve function is javascript code. its works fine for admin users.but it's throwing an error for visitors and member users.

error is

Cannot invoke method or retrieve property from nul…nt.Taxonomy.TaxonomySession.GetTaxonomySession

I have used the below code

  var ctx = SP.ClientContext.get_current();
    var taxonomySession = SP.Taxonomy.TaxonomySession.getTaxonomySession(ctx);
    var termStore = taxonomySession.getDefaultSiteCollectionTermStore(); 
    var termsList = [];
    var termSet = termStore.getTermSet("5f9b30c9-6beb-45cb-bfeb-3a1fdc49159a");
    var terms = termSet.get_terms();
    ctx.load(terms);
    ctx.executeQueryAsync(
        function () {
           var navTerms = [];
           var temp1 = 0;

           var termEnumerator = terms.getEnumerator();
            while (termEnumerator.moveNext()) 
            {
                var parentTerm = termEnumerator.get_current();                              
                navTerms.push(parentTerm.get_terms());
                ctx.load(navTerms[temp1]);
                temp1++;
             }
            ctx.executeQueryAsync(function () {
               for (var j = 0; j < navTerms.length; j++) {
                   var terms = [];
                   for (var i = 0; i < navTerms[j].get_count() ; i++) {
                       var navTerm = navTerms[j].getItemAtIndex(i);
                       terms.push({ termName: navTerm.get_name(), TargetURL: navTerm.get_localCustomProperties()._Sys_Nav_SimpleLinkUrl });
                   }
                   if (terms.length > 0) {
                       termsList.push({ id: j, termSetName: navTerms[j].getItemAtIndex(0).get_pathOfTerm().split(";")[0], terms: terms })
                   }
               }

            }, function (sender, args) {
               console.log('Request failed ', sender, args);
            });   
        }, function (sender, args) {
            //failure loading groups
            console.log('failure loading groups ', sender, args);
        });

suggest any idea to resolve this issue for read permission users.

  • have you checked whether the terms are "available for tagging " ? – Gautam Sheth Mar 30 '17 at 5:13
  • Yes , the tagging is available. @GautamSheth – PGP Mar 30 '17 at 5:21
  • can you share the code to retrieve terms? – Gautam Sheth Mar 30 '17 at 5:23
  • i have updated my code – PGP Mar 30 '17 at 5:27

Your Answer

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

Browse other questions tagged or ask your own question.