1
public taxonomy() {
    SP.SOD.registerSod('sp.taxonomy.js',SP.Utilities.Utility.getLayoutsPageUrl('sp.taxonomy.js'));  
    SP.SOD.executeFunc('sp.taxonomy.js','SP.Taxonomy.TaxonomySession',function() {
        var rest:ListItemOperations=new ListItemOperations();
        var tSession =SP.Taxonomy.TaxonomySession.getTaxonomySession(rest.context);
        var termStores=tSession.get_termStores();
        rest.context.load(tSession);    
        rest.context.load(termStores);    
        rest.context.executeQueryAsync(function() {
            var termStoreEnum=termStores.getEnumerator();
            var termStore = "Term Stores: /n";
            while(termStoreEnum.moveNext){
                var currentTermStore=termStoreEnum.get_current();
                console.log(currentTermStore.get_name());
                var termStoreId=currentTermStore.get_id();
                var termStoreName=currentTermStore.get_name();
                termStore+="Name:"+termStoreName+"Id:"+termStoreId;
                console.log(termStore);
            }
       }
    }
}

I am using the above code is for fetching all the termstores from a current site in sharepoint. But the currentTermStore shows an undefined error.

What changes shall I make to get all the termstores?

1

I think you should change your iterator. JSOM array list enumerator doesn't have moveNext property, you should use a method instead:

while(termStoreEnum.moveNext()) {...}

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.