[SharePoint Tip] Adding a discussion reply item in a thread programatically#

One of those things where I think of...is this the best way to deal with it? :)
Situation: I have a standard discussion board list with a discussion thread in it. I want to add a reply programatically, to that discussion thread (not creating a new discussion).

There are two things to keep in mind when doing that:

  • The ThreadID field, which is an ID that should be the same in each thread.
  • The Ordering field, which is a timestamp when the item is created.

When you want to add a new item in the same thread, you should create a new list item, duplicate the ThreadID and the set the timestamp, which is a duplicate of the original thread, PLUS the new timestamp. In code something like this:

SPListItem newItem = discussionList.Items.Add();
newItem["Title"] = "Title of item";
newItem["Body"] = "Body Text";
newItem["ThreadID"] = [ThreadID of original thread];
newItem["Ordering"] = [Ordering of original thread] + DateTime.Now.ToString("yyyyMMddhhmmss");
newItem.Update();

I wonder where this is in the SDK...or anywhere else...

Thursday, July 21, 2005 7:19:12 AM UTC #     | 

 

All content © 2012, Mart Muller
On this page
This site
Calendar
<February 2012>
SunMonTueWedThuFriSat
2930311234
567891011
12131415161718
19202122232425
26272829123
45678910
Archives
Sitemap
Disclaimer

Powered by: newtelligence dasBlog 1.9.7174.0

The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

Send mail to the author(s) E-mail

Theme design by Jelle Druyts