1
var clientContext = new SP.ClientContext(siteUrl);
var oList = clientContext.get_web().get_lists().getByTitle('Privacy Statements');

var camlQuery = new SP.CamlQuery();
camlQuery.set_viewXml('<View><Query><Where><Eq><FieldRef Name="IsActive"/><Value Type="Integer">1</Value></Eq></Where><OrderBy><FieldRef Name="SortOrder"/></OrderBy></View></Query>');
this.collListItem = oList.getItems(camlQuery);

clientContext.load(collListItem);

clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));        
 }  

function onQuerySucceeded(sender, args) {

var listItemEnumerator = collListItem.getEnumerator();


while (listItemEnumerator.moveNext()) {
    var oListItem1 = listItemEnumerator.get_current();
    if (sessionStorage.getItem('Title') == null || JSON.parse(sessionStorage.getItem('Title')).indexOf(oListItem1.get_item('Title')) == -1)
    {

     while (listItemEnumerator.moveNext()) {
        var oListItem = listItemEnumerator.get_current();
            listTitle.push(oListItem.get_item('Title'));
            listUrl.push(oListItem.get_item('PrivacyStatementUrls').get_url()); 
            }
    }
}

Simple question I have this js script where I use a caml query Just wondering how I can get the length of the list after the query

  • you want number of items in the listcollection? – Aanchal Jun 27 '14 at 15:55
4

Use following :

var count = this.collListItem.get_count();

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.