I have below code, to fetch the count of sharepoint list items to auto generate next item number by incrementing it. But somehow it's only fetching count of list items per user (list is protected to show only resp user's items). i would it instead have get list of all items (irrespective of user). Any help would be appreciated.
<script src = "https://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js"type = "text/javascript" ></script>
<script type = "text/javascript">
var clientContext = null;
var web = null;
ExecuteOrDelayUntilScriptLoaded(AutoGenerate, "sp.js");
function AutoGenerate() {
clientContext = new SP.ClientContext.get_current();
web = clientContext.get_web();
var list = web.get_lists().getById(_spPageContextInfo.pageListId);
var camlQuery = new SP.CamlQuery();
camlQuery.set_viewXml('<View><Query></Query></View>');
this.listItems = list.getItems(camlQuery);
clientContext.load(listItems);
clientContext.executeQueryAsync(Function.createDelegate(this, this.onListItemsLoadSuccess),
Function.createDelegate(this, this.onQueryFailed));
}
function onListItemsLoadSuccess(sender, args) {
var AutoIncremental = "AA-XCSA-" + listItems.get_count();
$("input[title^='Request ID']").val(AutoIncremental);
$("input[title^='Request ID']").attr('disabled', 'disabled');
}
function onQueryFailed(sender, args) {
alert('request failed ' + args.get_message() + '\n' + args.get_stackTrace());
}
</script>