1

I am working with a Discussion board list. I need to create the whole list using CSOM from scratch. To which I was able to make the list and topic inside it as folders. But I am not able to add replies to those topics. If I add replies as ListItem it shows as Topic inside the topic.

I wanted to know how to add replies to topics and also how to add replies to replies.

1

You should be able to achieve your goal with Microsoft.SharePoint.Client.Utilities.Utility.CreateNewDiscussionReply method.

public static ListItem CreateNewDiscussionReply(
    ClientRuntimeContext context,
    ListItem parent
)

For reply to topic provide topic ListItem as a parameter and for reply to reply provide original reply ListItem as a parameter.

Example

 var replyItem = Microsoft.SharePoint.Client.Utilities.Utility.CreateNewDiscussionReply(ctx, topicItem);

 replyItem["Title"] = "Test Reply";
 replyItem["Body"] = "Test body Content";
 replyItem.Update();
 ctx.ExecuteQuery();
| improve this answer | |
  • Thanks, buddy. It really helped me a lot. One more thing, do you how to distinguish between reply to a topic and reply to a reply while reading the replies as items. – Subhanu Sharma Feb 6 at 14:32

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.