Tuesday, 30 June 2015

ECMA Script : Get list Item Count

In the below code, using ECMA Script , we get the data from some custom list and after that we can count the number of items in ECMA Script.




function retrieveListItems() {
var clientContext = SP.ClientContext.get_current();
    var oList = clientContext.get_web().get_lists().getByTitle('FacilityStatus');
 
    var camlQuery = new SP.CamlQuery();


    camlQuery.set_viewXml('<View><Query><Where><And><Eq><FieldRef Name=\'Process\' /><Value Type=\'Lookup\'>Physical Space Allocation</Value></Eq><Eq><FieldRef Name=\'FacilityName\' /><Value Type=\'Lookup\'>Training Room</Value></Eq></And></Where></Query></View>');

    this.collListItem = oList.getItems(camlQuery);
           
    clientContext.load(collListItem);
   

    clientContext.executeQueryAsync( function () {  count= collListItem.get_count(); } ,function(){alert(":(");});              
}

</script>

No comments:

Post a Comment