Skip to main content

Can anyone help on this.

iI am getting the below error.

The collection has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested.

The collection has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested.

following is the code.

$(document).ready(function(){

$(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");
            // SP.SOD.executeOrDelayUntilScriptLoaded('SP.taxonomy.js');
            ExecuteOrDelayUntilScriptLoaded(execOperation, "sp.taxonomy.js");
        });
    });
});

});

function execOperation(){



function execOperation(){

    var context = new SP.ClientContext.get_current();    
    console.log(context);
    //Current Taxonomy Session
    var taxSession = SP.Taxonomy.TaxonomySession.getTaxonomySession(context);
    //Term Stores
    var termStores = taxSession.get_termStores();
    //Name of the Term Store from which to get the Terms.
    var termStore = termStores.getByName("Managed Metadata Service");
    //GUID of Term Set from which to get the Terms.
    var termSet = termStore.getTermSet("8a675225-852f-48ed-af73-8fd8e5ccdc14");
    var terms = termSet.getAllTerms();
    context.load(terms);
var    termEnumerator = terms.getEnumerator();

    context.executeQueryAsync(function(){
        var termEnumerator = terms.getEnumerator();
        var termList = "Terms: \n";
        while(termEnumerator.moveNext()){
            var currentTerm = termEnumerator.get_current();
            termList += currentTerm.get_name() + "\n";
        } 

        alert(termList);

    }, function(sender,args){

        console.log(args.get_message());
 
    });
}

Can anyone help on this.

i am getting the below error.

The collection has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested.

following is the code.

$(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");
         // SP.SOD.executeOrDelayUntilScriptLoaded('SP.taxonomy.js');
          ExecuteOrDelayUntilScriptLoaded(execOperation, "sp.taxonomy.js");
        });
    }
);

});

function execOperation(){

 var context = new SP.ClientContext.get_current();    
 console.log(context);
//Current Taxonomy Session
var taxSession = SP.Taxonomy.TaxonomySession.getTaxonomySession(context);
//Term Stores
var termStores = taxSession.get_termStores();
//Name of the Term Store from which to get the Terms.
var termStore = termStores.getByName("Managed Metadata Service");
//GUID of Term Set from which to get the Terms.
var termSet = termStore.getTermSet("8a675225-852f-48ed-af73-8fd8e5ccdc14");
var terms = termSet.getAllTerms();
context.load(terms);
var termEnumerator = terms.getEnumerator();

context.executeQueryAsync(function(){
 var termEnumerator = terms.getEnumerator();
 var termList = "Terms: \n";
    while(termEnumerator.moveNext()){
        var currentTerm = termEnumerator.get_current();
        termList += currentTerm.get_name() + "\n";
    } 

      alert(termList);

},function(sender,args){

      console.log(args.get_message());
 
});

Can anyone help on this.

I am getting the below error.

The collection has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested.

following is the code.

$(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");
            // SP.SOD.executeOrDelayUntilScriptLoaded('SP.taxonomy.js');
            ExecuteOrDelayUntilScriptLoaded(execOperation, "sp.taxonomy.js");
        });
    });
});


function execOperation(){

    var context = new SP.ClientContext.get_current();    
    console.log(context);
    //Current Taxonomy Session
    var taxSession = SP.Taxonomy.TaxonomySession.getTaxonomySession(context);
    //Term Stores
    var termStores = taxSession.get_termStores();
    //Name of the Term Store from which to get the Terms.
    var termStore = termStores.getByName("Managed Metadata Service");
    //GUID of Term Set from which to get the Terms.
    var termSet = termStore.getTermSet("8a675225-852f-48ed-af73-8fd8e5ccdc14");
    var terms = termSet.getAllTerms();
    context.load(terms);
    termEnumerator = terms.getEnumerator();

    context.executeQueryAsync(function(){
        var termEnumerator = terms.getEnumerator();
        var termList = "Terms: \n";
        while(termEnumerator.moveNext()){
            var currentTerm = termEnumerator.get_current();
            termList += currentTerm.get_name() + "\n";
        } 

        alert(termList);

    }, function(sender,args){

        console.log(args.get_message());
    });
}
Source Link

How to get the values of term store using JSOM?

Can anyone help on this.

i am getting the below error.

The collection has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested.

following is the code.

$(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");
         // SP.SOD.executeOrDelayUntilScriptLoaded('SP.taxonomy.js');
          ExecuteOrDelayUntilScriptLoaded(execOperation, "sp.taxonomy.js");
        });
    }
);

});

function execOperation(){

 var context = new SP.ClientContext.get_current();    
 console.log(context);
//Current Taxonomy Session
var taxSession = SP.Taxonomy.TaxonomySession.getTaxonomySession(context);
//Term Stores
var termStores = taxSession.get_termStores();
//Name of the Term Store from which to get the Terms.
var termStore = termStores.getByName("Managed Metadata Service");
//GUID of Term Set from which to get the Terms.
var termSet = termStore.getTermSet("8a675225-852f-48ed-af73-8fd8e5ccdc14");
var terms = termSet.getAllTerms();
context.load(terms);
var termEnumerator = terms.getEnumerator();

context.executeQueryAsync(function(){
 var termEnumerator = terms.getEnumerator();
 var termList = "Terms: \n";
    while(termEnumerator.moveNext()){
        var currentTerm = termEnumerator.get_current();
        termList += currentTerm.get_name() + "\n";
    } 

      alert(termList);

},function(sender,args){

      console.log(args.get_message());

});