I am trying to fetch list items along with its Attachments and display on a SharePoint page using JavaScript JSOM.
My code contains the pagination too which is mentioned here.
Now, for attachment we have to load the AttachmentFiles field separately. So what I did is,
context = new SP.ClientContext(_spPageContextInfo.siteAbsoluteUrl);
list = context.get_web().get_lists().getByTitle(ListName);
camlQuery = new SP.CamlQuery();
camlQuery.set_listItemCollectionPosition(position);
camlQuery.set_viewXml('myCamelQuery');
spItems = list.getItems(camlQuery);
context.load(spItems,'Include(AttachmentFiles,and all remaining fields)');
context.executeQueryAsync(
// My codes );
As mentioned in managePagerControl() method in given link, I have following code:
if (spItems.get_listItemCollectionPosition()) {
nextPagingInfo = spItems.get_listItemCollectionPosition().get_pagingInfo();
} else {
nextPagingInfo = null;
}
Now, this code gives error,
The property or field 'ListItemCollectionPosition' has not been initialized. It has not been requested or the request has not been executed
So, How to get rid of this error or How can I include ListItemCollectionPosition field too in my request? using ViewFields too give same error.
ListItemCollectionPositionfield too, including this filed inIncludealso throws error – Trimantra Software Solution Jun 01 '17 at 12:15