I have used below code to get all the items of the list .But I am getting error as "List Name is Undefined with below code".

But When I use rest _api/web/lists/GetByTitle('Tabletop Sessions')/items in browser. It is adding "%" (_api/web/lists/GetByTitle('Tabletop%20Sessions')/items) and showing the result.

Can any one tell me what's wrong in my below code in calling the list name

   function getprogrames(sender, args)
          alert("in Programes");
          var clientContext = new SP.ClientContext.get_current();
          alert("Recevied SP Context");
          var oList = clientContext.get_web().get_lists().getByTitle('Tabletop Sessions');
         var oList = clientContext.get_web().get_lists().getById('{7047BB0C-ED2B-4980-A61B-4D888102AEA9}');
          var camlQuery = new SP.CamlQuery();
          camlQuery.set_viewXml("<View><Query><Where><Eq><FieldRef Name='Title'/></Query></View>");
          this.collListItem = oList.getItems(camlQuery);
          alert("Retrived and Loaded to Programes");
          Function.createDelegate(this, this.onprogramQuerySucceeded),
          Function.createDelegate(this, this.onQueryFailed)

    function onprogramQuerySucceeded(sender, args)
        alert("into Success Function Of Programs to bind into Dropdownlist");
        var listItemInfo = '';
        var listItemEnumerator = collListItem.getEnumerator();

        var functions = document.getElementById("drbprogrames");

        while (listItemEnumerator.moveNext())
            var oListItem = listItemEnumerator.get_current();

            listItemInfo =oListItem.get_item('Title');

            var option = document.createElement('option');
            option.text = option.value = listItemInfo;

   function onQueryFailed(sender, args) {
    alert('Request failed. ' + args.get_message() +
     '\n' + args.get_stackTrace());
  • Can you confirm after alert("Recevied SP Context"); statement, you are executing one out of two line? Since, in next two lines have declared same variable. – ThinkB4Code Mar 1 '18 at 4:03
  • use this var oList = clientContext.get_web().get_lists().getById('7047BB0C-ED2B-4980-A61B-4D888102AEA9'); and check – Gautam Sheth Mar 1 '18 at 4:29
  • Find no luck from you both – MSA Mar 1 '18 at 5:07
  • @MSA Does your web have multiple languages enabled? The list name can be different for different language, which can cause troubles. – Lukas Nespor Mar 1 '18 at 12:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.