Retrieve all lists and libraries from SharePoint site using JavaScript object model in SharePoint online

Retrieve all lists and libraries from SharePoint site using JavaScript object model in SharePoint online
InfoPath alternatives for form designing SharePoint

Here we will discuss how we can retrieve all lists and libraries from SharePoint site using JavaScript object model in SharePoint online Office 365.

Here we have put the code inside a script editor web part inside a web part page. If you face one issue like Uncaught TypeError: SP.ClientContext is not a constructor error, then you can resolve by following this article.

Also you can check:
– Create folder inside document library using Rest API in SharePoint Online Office 365

– Microsoft Flow Copy files from one SharePoint Online account or folder to another Office 365

– SharePoint Online Develop SharePoint Hosted Add-in using Visual Studio 2015 Demo

<script src=”https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js”></script>

<div id=”divGetListData”></div>

<script>

$(function () {

ExecuteOrDelayUntilScriptLoaded(getAllLists, “sp.js”);

});

function getAllLists() {

var clientContext = new SP.ClientContext();

var oWebsite = clientContext.get_web();

this.collList = oWebsite.get_lists();

clientContext.load(collList);

clientContext.executeQueryAsync(

Function.createDelegate(this, this.onQuerySucceeded),

Function.createDelegate(this, this.onQueryFailed)

);

}

function onQuerySucceeded() {

var listInfo = ”;

var listEnumerator = collList.getEnumerator();

while (listEnumerator.moveNext()) {

var oList = listEnumerator.get_current();

listInfo += oList.get_title() + ‘<br />’;

}

$(“#divGetListData”).html(listInfo);

}

function onQueryFailed(sender, args) {

alert(‘Request failed. ‘ + args.get_message() +

‘\n’ + args.get_stackTrace());

}

</script>

Once you will save this code it will display all the lists and libraries like below:

 Retrieve all lists and libraries from SharePoint site using JavaScript object model in SharePoint online
Retrieve all lists and libraries from SharePoint site using JavaScript object model in SharePoint online

Hope this will be helpful.

Similar SharePoint 2013 Tutorials

About Bijay Kumar

I am Bijay from Odisha, India. Currently working in my own venture TSInfo Technologies in Bangalore, India. I am Microsoft Office Servers and Services (SharePoint) MVP (5 times). I works in SharePoint 2016/2013/2010, SharePoint Online Office 365 etc. Check out My MVP Profile.. I also run popular SharePoint web site SharePointSky.com

View all posts by Bijay Kumar →

Leave a Reply