Hi,
Below is the sample script we used to get the total listitems that have MarkAsUnread ( Yes/No) Column value set as No (i.e. 0)
var myItems;
function GetCount() {
debugger;
var queryListItem = '<View><Query><Where><Eq><FieldRef Name="MarkAsRead" /><Value Type="Boolean">0</Value></Eq></Where></Query></View>';
var siteUrl = window.location.protocol + "//" + window.location.host;
var clientContext = new SP.ClientContext(siteUrl);
var oList = clientContext.get_web().get_lists().getByTitle('Notification Centre');
var myquery = new SP.CamlQuery();
myquery.set_viewXml(queryListItem);
myItems = oList.getItems(myquery);
clientContext.load(myItems);
clientContext.executeQueryAsync(
Function.createDelegate(this, this.onQuerySucceeded),
Function.createDelegate(this, this.onQueryFailed)
);
}
function onQuerySucceeded(sender, args) {
alert(myItems.get_count());
}
function onQueryFailed(sender, args) {
alert('Request failed. ' + args.get_message() +'\n' + args.get_stackTrace());
}
Hope it helps
Discover more from Nishant Rana's Weblog
Subscribe to get the latest posts sent to your email.

Reblogged this on Sutoprise Avenue, A SutoCom Source.
LikeLike
hi will this work if query return more than 5000 items
LikeLike
The script works only for users with administrator permissions. For other users the script returns value 0.
LikeLike