I'm new to NAPA tool. I started to build simple apps using NAPA tool. And I tried to access a list in office 365 site using below code. After I publish the app it shows an error message: Message: List 'Announcements' does not exist at site with URL



is my site and SharePointApp3 is my app name. At glance


has Announcements list and


doesn't have. Can anyone suggest to solve this.

<script type="text/javascript">
        //This example gets all the items in the Announcements list that have a title that begins with 'T'.
        //If your site doesn't include a list called Announcements you must make the changes indicated

        //This variable will hold a reference to the Announcements list items collection
        var returnedItems = null;

        //This function loads the list and runs the query asynchronously
        function queryListItems() {
            //Get the current context
            var context = new SP.ClientContext();
            //Get the Announcements list. Alter this code to match the name of your list
            var list = context.get_web().get_lists().getByTitle('Announcements');
            //Create a new CAML query
            var caml = new SP.CamlQuery();
            //Create the CAML that will return only items with the titles that begin with 'T'
            caml.set_viewXml("<View><Query><Where><BeginsWith><FieldRef Name='Title' /><Value Type='Text'>T</Value></BeginsWith></Where></Query></View>");
            //Specify the query and load the list oject
            returnedItems = list.getItems(caml);
            //Run the query asynchronously, passing the functions to call when a response arrives
            context.executeQueryAsync(onSucceededCallback, onFailedCallback);

        //This function fires when the query completes successfully
        function onSucceededCallback(sender, args) {
            //Get an enumerator for the items in the list
            var enumerator = returnedItems.getEnumerator();
            //Formulate HTML from the list items
            var markup = 'Items in the Announcements list that start with "T": <br><br>';
            //Loop through all the items
            while (enumerator.moveNext()) {
                var listItem = enumerator.get_current();
                markup += 'Item Title: ' + listItem.get_item('Title') + '<br>';
                markup += 'Item ID: ' + listItem.get_id() + '<br><br>';
            //Display the formulated HTML in the displayDiv element
            displayDiv.innerHTML = markup;

        //This function fires when the query fails
        function onFailedCallback(sender, args) {
            //Formulate HTML to display details of the error
            var markup = '<p>The request failed: <br>';
            markup += 'Message: ' + args.get_message() + '<br>';
            //Display the details
            displayDiv.innerHTML = markup;
  • I haven't used NAPA Tools, so I don't know how the app gets deployed. But with apps, they usually get deployed to a different domain than the host. So your code would be searching the app domain for the list, which does not exist (unless you did create a list in the app?). – wjervis Jul 14 '14 at 11:41

You have to get the context of the site where you have your list. The below code should work:

var context = new SP.AppContextSite(SP.ClientContext.get_current(), 'https://URL/sites/DevSite/');
var list = context.get_web().get_lists().getByTitle('Announcements');

Edit: You will also need to give permission for the app on the site (Host Web). You can do that in Napa from Left Ribbon Properties -> Permissions.

| improve this answer | |

I am assuming you need to access host web announcement list, for doing so you need to get client context of the host web even before you do this

var list = context.get_web().get_lists().getByTitle('Announcements');

Also, try to do some reading on SharePoint App Architecture. How App Web and Host Web are different.

| improve this answer | |

Your Answer

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

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