title: Sharepoint javascript get_id error
body: <p>Alright, this one's got me seriously stumped, after trying things out for hours with the block of javascript below I'm still getting the same error in IE's javascript debugger.</p>
  
  <p>The error I'm getting is SCRIPT5007: Unable to get value of the property 'get_id': object is null or undefined.</p>
  
  <p>And below is my code:</p>
  
  <pre><code>AS.SP.ClientActions.ClientProgramEdit_Status = new AS.SP.ClientActions.ButtonStatus();
  AS.SP.ClientActions.Can_ClientProgramEdit = function (groupID) {
  
  var OnError = function (sender, args) {
      AS.SP.ClientActions.ClientProgramEdit_Status.enabled = false;
      RefreshCommandUI();
  };
  
  var items = AS.SP.ClientActions.GetSelectedItems();
  var count = CountDictionary(items);
  if (count === 1) {
      var itemID = items[0].id;
      if (AS.SP.ClientActions.ClientProgramEdit_Status.itemID != itemID) {
          AS.SP.ClientActions.ClientProgramEdit_Status.itemID = itemID;
          AS.SP.ClientActions.ClientProgramEdit_Status.enabled = false;
  
          AS.SP.ClientActions.GetUrl(function (rootUrl) {
              var fragments = AS.SP.Navigation.ParseUri(rootUrl);
  
              var ctx = new SP.ClientContext(fragments.path); 
              var web = ctx.get_web();
              var props = web.get_allProperties();
  
              ctx.load(web);
              ctx.load(props);
              ctx.executeQueryAsync(function () {
  
                  var listId = 'Client Programs';
                  var sdlist = web.get_lists().getByTitle(listId);
  
                  var locationID = props.get_item('WL_ITEM_ID');
                  var query = new SP.CamlQuery();
                  query.set_viewXml('&lt;View&gt;&lt;Query&gt;&lt;Where&gt;&lt;And&gt;&lt;Eq&gt;&lt;FieldRef Name="len_cp_Location" /&gt;&lt;Value Type="Text"&gt;' + locationID + '&lt;/Value&gt;&lt;/Eq&gt;&lt;Eq&gt;&lt;FieldRef Name="len_cp_Client_Status" /&gt;&lt;Value Type="Text"&gt;Inactive&lt;/Value&gt;&lt;/Eq&gt;&lt;/And&gt;&lt;/Where&gt;&lt;/Query&gt;&lt;ViewFields&gt;&lt;FieldRef Name="Title" /&gt;&lt;/ViewFields&gt;&lt;/View&gt;');
                  var items = sdlist.getItems(query);
                  ctx.load(items);
                  ctx.executeQueryAsync(function () {
                      var item = items.itemAt(0);
                      var itemID = item.get_id();
  
                      if (itemID == "WL_ITEM_ID") {
                          AS.SP.ClientActions.ClientProgramEdit_Status.enabled = true;
                          RefreshCommandUI();
                      }
                  }, OnError);
              }, OnError);
          });
      }
  }
  
  return AS.SP.ClientActions.ClientProgramEdit_Status.enabled;
  }
  </code></pre>
  
  <p>My theory is that I've done something wrong with my CAML query but at this point I really don't know, any help with this would be greatly appreciated, thanks!</p>