How to Get SharePoint List Items Count in Sharepoint 2013 /Office 365?

In SharePoint 2013/Office 365, we do lot of customizations using CSOM. One of the most required validation you do when you are manipulating with the list of items is to find out the exact count of the list items. There are many ways to achieve this. This is the simplest way to find out the list count in a sharepoint list is below.

var clientContext = new SP.ClientContext.get_current();
var oList = clientContext.get_web().get_lists().getByTitle(‘MYCUSTOMLIST’);

var camlQuery = new SP.CamlQuery();
camlQuery.set_viewXml(‘<View><Query><Where><Geq><FieldRef Name=\’ANYFIELD_x0020_Name\’/>’ +
‘<Value Type=\’Text\’>’ + currentUser + ‘</Value></Geq></Where></Query></View>’);
this.collListItem = oList.getItems(camlQuery);


Hope the below code helps!  Happy SharePointing folks!!


Leave a Reply

Your email address will not be published. Required fields are marked *