0

I retrieve all items by using this code:

var oList = context.Web.Lists.GetByTitle(title);
CamlQuery camlQuery = new CamlQuery();
camlQuery.ViewXml = "<View Scope=\"RecursiveAll\"></View>";
ListItemCollection collListItem = oList.GetItems(camlQuery);
context.Load(collListItem, x=> x.Take(100));
context.ExecuteQuery();

foreach (var batch in collListItem.Batch(100))
{
     foreach (var item in batch)
     {
          context.Load(item);
     }
     context.ExecuteQuery();
}
return collListItem.Select(Map);

Each item has Comments field. But, it does not contain all comments.

How to retrieve all comments of item?

0

Suppose the Comments field is a plain multiline text field, then modified the code as below:

            ClientContext context = new ClientContext("http://sp/sites/dev");
            var oList = context.Web.Lists.GetByTitle("CommentsList");
            CamlQuery camlQuery = new CamlQuery();
            camlQuery.ViewXml = "<View Scope=\"RecursiveAll\"></View>";
            ListItemCollection collListItem = oList.GetItems(camlQuery);
            context.Load(collListItem, x => x.Take(100));
            context.ExecuteQuery();

            foreach (var item in collListItem)
            {
                Console.WriteLine(item["Comments"].ToString());
            }

enter image description here

enter image description here

  • Is CommentsList hidden list on server? I don't see it if I enumerate all lists. – eocron Mar 1 at 15:15
  • There is no CommentsList in SharePoint, this should be a field which allow user to add comment in a list item. – Jerry_MSFT Mar 1 at 15:21
  • It has type of SPFieldNote. – eocron Mar 1 at 19:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.