0

I am trying to load a list that exists in multiple subsites in a given site collection. as I enumerate for-each web in the site collection I am loading a particular list by Title.

I am having trouble getting a context to the list being loaded in the callback, however I can see it in the f12 developer tools in the browser.

Can someone give us more info on SP.ClientRequest?

Here is some code:

    // other code was redacted
    onSummaryListLoad : function (sender, args) { 
        // want to get a reference to 'summarylist' here from 'sender'  
    },
    onLoadSubWebs : function (sender, args) {
        //function () {  
            console.log('loaded subwebs successfully');   

            var webs = this.subWebs.getEnumerator();
            while (webs.moveNext()) {
                var thisWeb = webs.get_current();
                console.log(thisWeb.get_title());
                this.summarylist = thisWeb.get_lists().getByTitle('Project Summary');
                context.load(this.summarylist, "DefaultDisplayFormUrl");
                context.executeQueryAsync(Function.createDelegate(this, this.onSummaryListLoad), Function.createDelegate(this, this.APICallFailed)); 
            }
    // other code was redacted

Image from the Browser Tools:

enter image description here

Thank!!!!!

1 Answer 1

1

I asked myself the same question (other context, but with executeQueryAsync). In my case it was a startWorkflow function where I needed the $15_0 from

var startWFReq = wfsManager.getWorkflowInstanceService().startWorkflow(...)
ctx.executeQueryAsync(
//success function
   function (sender, args) {
       //in this case startWFReq equals sender.$15_0["18"]
       console.log(startWFReq);
   },
// fail function
   function(sender, args){

   }

So in your case I should try to use this:

onSummaryListLoad : function (sender, args) { 
    // want to get a reference to 'summarylist' here from 'sender'  
    //reference to summarylist:
    this.summarylist
},
onLoadSubWebs : function (sender, args) {
    //function () {  
        console.log('loaded subwebs successfully');   

        var webs = this.subWebs.getEnumerator();
        while (webs.moveNext()) {
            var thisWeb = webs.get_current();
            console.log(thisWeb.get_title());
            this.summarylist = thisWeb.get_lists().getByTitle('Project Summary');
            context.load(this.summarylist, "DefaultDisplayFormUrl");
            context.executeQueryAsync(Function.createDelegate(this, this.onSummaryListLoad), Function.createDelegate(this, this.APICallFailed)); 
        } 

Allthough I doubt that the scope will be ok. So I should take a look here: http://blog.mannsoftware.com/?p=353 And make something like this

createDelegate(equal_to_the_web_id_inside_the_loop, this.onSummaryListLoad)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.