Facing Error Unable to Get List,Please Help Me currently tying to create SharePoint Hosted App(Image Slide) on my AppDev Site https://akki.sharepoint.com/sites/appdev
I have Created Picture Library on above site with name "Image Slider"
Using Napa tool Created project "Picture Slider"
inside APP.js write Some Logic s as follow
'use strict';
var siteUrl="http://akki.com/sites/AppDev";
var context = new SP.ClientContext.get_current();// (siteUrl);
//var user = context.get_web().get_currentUser();
var libraryName ="Image Slider";
var libraries;
var items;
(function () {
$(document).ready(function () {
loadSharePointPictures();
});
function loadSharePointPictures() {
// var context = new SP.ClientContext.get_current();
var web = context.get_web();
libraries = web.get_lists();
context.load(libraries);
context.executeQueryAsync(IsListExist,errorFunction)
}
//check whether list is exist or not
function IsListExist() {
//debugger;
//alert('check whether list is exist or not');
var isListAvail = false;
var listEnumerator = libraries.getEnumerator();
while (listEnumerator.moveNext()) {
var currentlibrary = listEnumerator.get_current();
//check whether the library name is equal to current library
if (currentlibrary.get_title() == libraryName) {
isListAvail = true;
//Retrieve list items from the lists
getListItemCollection();
}
}
if (!isListAvail) {
alert('Image Slider Picture Library is not available in this site');
}
}
function errorFunction(){
//console.log("error");
alert('error');
}
//Get image collection from Library
function getListItemCollection() {
//debugger;
var library=libraries.getByTitle(libraryName);
var CamelQuery=new SP.CamlQuery();
CamelQuery.set_viewXml(
"<view>"+
"<Query>"+
"<Where>" +
"<IsNotNull>" +
"<FieldRef Name='EncodedAbsUrl' />" +
"</IsNotNull>" +
"</Where>"+
"<Query>"+
"</view>");
items=library.getItems(CamelQuery);
context.load(items);
context.executeQueryAsync(OnGetListItemSuccess,OnGetListItemFailure);
}
//Get Image name from Library
function OnGetListItemSuccess() {
//debugger;
if(items.get_count()>0)
{
var enumarator=items.getEnumerator();
while (enumarator.moveNext())
{
var CurrentListItem=enumarator.get_current();
var imagePath=CurrentListItem.get_item("EncodedAbsUrl");
var link=CurrentListItem.get_item("URL");
//Create Html div tag
var div = document.createElement("div");
var itemClass=document.createAttribute("class");
itemClass.value="item";
div.setAttributeNode(itemClass);
//Create Html anchor tag
var anchor=document.createElement("anchor");
var href=document.createAttribute("href");
href.value=link;
anchor.setAttributeNode(href);
//Create Html image tag
var image=document.createElement("image");
var src=document.createAttribute("src");
src.value=imagePath;
image.setAttributeNode(src);
//Append Elements
anchor.appendChild(image);
div.appendChild(anchor);
//document.body.appendChild(div);
$('.carousel-inner').appendChild(div);
}
}
}
function OnGetListItemFailure(sender, args) {
alert('Failed to get Items. Error:' + args.get_message());
}
})();
Facing Error Unable to Get List,Please Help Me