SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am currently trying to determine the length of a list that is located on my SharePoint site. I am using a Caml query to retrieve the items in my list, but I can not figure out how to get the length of the result. I am using the Client Object Model and javascript / Ajax / jquery etc...

var context = new SP.ClientContext.get_current();
    var query = new SP.CamlQuery();
    var currentweb = context.get_web();

    query.set_viewXml('<View>' +
                                        '<IsNotNull>' +
                                            '<FieldRef Name="ID" />'+
                                        '</IsNotNull>' +
                                    '<FieldRef Name="Name"/>'+

    var colList= currentweb.get_lists().getByTitle("MyList");

    this.docList= colList.getItems(query);

When the code runs context.ExecuteQuery() the console prints out this.

context.ExecuteQuery is not a function
share|improve this question
up vote 2 down vote accepted

The javaScript (and SilverLight) client object model doesn't implement clientContext.ExecuteQuery only the ExecuteQueryAsync(successDelegate, failDelegate)

share|improve this answer
Sure it does. At least in SilverLight. I've used it before, and just checked to make sure I wasn't crazy. It's there. It works. – RJ Cuthbertson Apr 4 '12 at 20:40
Obviously that is the case in javaScript though, seeing the above error that's thrown. – RJ Cuthbertson Apr 4 '12 at 20:42
@rjcup3 Well the SilverLight has it, but only if running outside UI thread, so it's generally discouraged to use it. JavaScript doesn't even have it, which is probably a better approach – Per Jakobsen Apr 4 '12 at 21:10
Why would you want to perform non-UI actions on the UI thread? I only use the UI thread for the UI... I do generally use the asynchronous model, but I have used queries synchronously if they need to be executed in direct succession (ie: data from query A is used in query B, which returns data used in query C). It's just easier to keep them all in one function. – RJ Cuthbertson Apr 5 '12 at 0:45

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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