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

bimbob
  • 461
  • 4
  • 14
  • 27

1 Answers1

4

Use following :

var count = this.collListItem.get_count();

Taran Goel
  • 4,474
  • 5
  • 20
  • 44
Aanchal
  • 7,885
  • 1
  • 15
  • 20