Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have created a new page on my sharepoint site. I have embedded some html using the embed code

<!DOCTYPE html>


I have a js file which includes :

var siteUrl = 'http://mysite/';

function retrieveAllListProperties() {

var clientContext = new SP.ClientContext(siteUrl);
var oWebsite = clientContext.get_web();
this.collList = oWebsite.get_lists();


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 += 'Title: ' + oList.get_title() + ' Created: ' + oList.get_created().toString() + '\n';

function onQueryFailed(sender, args) {
alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());

I have 2 questions first how can I get my javascript file to run in my page. Secondly how can I count how many items are in a particular list and then print it out to my page

share|improve this question

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.