I am attempting to reference a document library in JavaScript. From what I have read, I should be able to open the library using something similar to the following:
list = web.get_lists().getByTitle("Vacation NonTravel Requests");
The problem here is that I cannot get the list via this request- rather, I receive the error List 'Vacation NonTravel Requests' does not exist at site with URL ...
. I assume this is because I am not dealing with the spaces properly, but when I navigate to the library, the URL shows it with spaces. Regardless, I have tried replacing them with _x0020_
as SharePoint seems to do with some field names (replacing the double space with _x0020__x0020_
, _x0020_x0020_
, and _x0020x0020_
, each with no success), and I have tried simply removing the spaces. I'm not sure what to try next, or even if this is actually the reason for my error message. Has anyone dealt with this before?
EDIT: I have also tried replacing the spaces with %20
, but still no luck
EDIT: As requested, following is all of the relevant code:
list = web.get_lists().getByTitle('Vacation NonTravel Requests');
var collListItems2 = list.getItems(SP.CamlQuery.createAllItemsQuery());
context.load(collListItems2);
context.executeQueryAsync(
function(){
alert('success');
},
function(){alert('fail');}
);
Just before this, I have a similar query (on a list) that is working fine. I use collListItems2
here in case the issue has to do with the variable being in use, and I have created duplicates of both the context
and the web
variables for the same purpose.