I am using SharePoint Client Object Model (CSOM) to reply to an existing Discussion on a Sharepoint Online 2013 site using the following code
SP.ListItem oListItem = SP.Utilities.Utility.CreateNewDiscussionReply(ctx, parentListItem);
oListItem.Update();
ctx.ExecuteQuery();
oListItem["Body"] = "Reply msg Body.";
oListItem.Update();
ctx.ExecuteQuery();
Though, for a TeamSite, if I try to reply to an existing Discussion then the code is running successfully.
However, for a CommunitySite, the same code runs successfully but when I try to Load all the ListItems of this Discussion List, Value Does not Fall within the Expected Range, error is thrown. following is the code snippet that I am using to Load all the ListItems.
SP.CamlQuery camlQuery = new SP.CamlQuery();
camlQuery.ViewXml = "<View Scope=\"RecursiveAll\" />";
listItemCollection = list.GetItems(camlQuery);
ctx.Load(listItemCollection);
ctx.ExecuteQuery();
So is this a bug, or I need to create the Discussion and its reply differently? I tested this behavior with the SharePoint.Client dll from both v15 as well as v16.