Ever tried to use C# to add list items to Tasks list? Annoumcements? piece of cake.
To a Document Library? saving a file, updaging meta data - no problem.
But - did you ever try to create a new discussion on a Discussion Board? Well, there is more to it than you think.
My customer had me create a new discussion automatically for every task created on the site. This way - when ever you assign a task to a group or a person they can communicate with each other and work a solution together.
Doing a little research i found that creating a new discussion is a bit different than working with a normal list that we are used to.
First you must create a new discussion using the SPUtility.CreateNewDiscussion method.
This method reiceves the name of the discussion and the SPListItemCollection of the SPList item representin the discussion.
well, for example if you have a discussion boared called "What say you" your code should look like this:
SPList list = web.Lists["What say you"];
SPListItemCollection myListItems = list.Items;
SPListItem d = SPUtility.CreateNewDiscussion(myListItems, "Talk about Task X");
d["Body"] = "What say you about task X?";
And a reply will look like this:
SPListItem r = SPUtility.CreateNewDiscussionReply(d);
r["Body"] = "Looks interesting... Doesnt it?";
Well, hope this helps...