title: SCRIPT5022: The collection has not been initialized. It has not been requested or the request has not been executed
body: <p>i have a simple javascript which throws me the following error:</p>
  
  <p>SCRIPT5022: 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.</p>
  
  <p>I am using it under O365 inside an Content Editor WebPart. I have a list called "myTestList" with several items and one column called "points". I want to retrieve only the items which i have created and sum the points to show it inside a div. This is my code.</p>
  
  <pre><code>&lt;div id="myPoints" style="font-size: 50px;"&gt;0​&lt;/div&gt; 
  
  &lt;script language="javascript" type="text/javascript"&gt;
  
  SP.SOD.executeOrDelayUntilScriptLoaded(retrieveMyItems, "sp.js");
  
  function retrieveMyItems() {
      var clientContext = new SP.ClientContext.get_current();
      var oList = clientContext.get_web().get_lists().getByTitle('myTestList');
  
      var camlQuery = new SP.CamlQuery();
      camlQuery.set_viewXml("&lt;View&gt;&lt;Query&gt;&lt;Where&gt;&lt;Eq&gt;&lt;FieldRef Name='Author' /&gt;&lt;Value Type='Integer'&gt;&lt;UserID /&gt;&lt;/Value&gt;&lt;/Eq&gt;&lt;/Where&gt;&lt;/Query&gt;&lt;/View&gt;");
      this.collListItem = oList.getItems(camlQuery);
  
      clientContext.load(collListItem, 'Include(points)');
  
      clientContext.executeQueryAsync(Function.createDelegate(this, this.onMyItemsQuerySucceeded), Function.createDelegate(this, this.onMyItemsQueryFailed));
  }
  
  function onMyItemsQuerySucceeded(sender, args) {
      var listItemInfo = 0;
      var listItemEnumerator = collListItem.getEnumerator();
  
      while (listItemEnumerator.moveNext()) {
          var oListItem = listItemEnumerator.get_current();
          listItemInfo = listItemInfo + parseInt(oListItem.get_item('points'));
      }
  
      var div = document.getElementById("myPoints");
      div.innerHTML = listItemInfo;
  }
  
  function onMyItemsQueryFailed(sender, args) {
      alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
  }
  
  &lt;/script&gt;​
  </code></pre>
  
  <p>Whats wrong here?</p>
  
  <p><strong>Update</strong>
  Solved! The set_viewXml</p>
  
  <pre><code>camlQuery.set_viewXml("&lt;View&gt;&lt;Query&gt;&lt;Where&gt;&lt;Eq&gt;&lt;FieldRef Name='Author' /&gt;&lt;Value Type='Integer'&gt;&lt;UserID Type='Integer'/&gt;&lt;/Value&gt;&lt;/Eq&gt;&lt;/Query&gt;&lt;/Where&gt;&lt;/View&gt;");
  </code></pre>
  
  <p>I had to add <strong></strong>.</p>