As we know, Sharepoint 2010 offers only one level of Discussion group (at least as far as I know) i.e., First level is Discussion Group and the inner level is Discussion Threads (individual posts).
What did I do, I create the discussion group programmatically and move the created group under an existing discussion group. This way, I was able to achieve multiple levels of discussion groups.
var web = SPContext.Current.Web; var discussionList = web.Lists[DISCUSSION_LIST_NAME]; var discussionContentType =
web.AvailableContentTypes[DISCUSSION_CONTENT_TYPE_NAME];
web.AllowUnsafeUpdates = true;
var newDiscussionItem = SPUtility.CreateNewDiscussion(discussionList, title); newDiscussionItem["Title"] = title; newDiscussionItem["ContentTypeId"] = discussionContentType.Id; newDiscussionItem["ContentType"] = discussionContentType.Name;
newDiscussionItem.Update();
//if the discussion group is a child discussion (Thread)
//then move the discussion group
//to a sub level (under its parent discussion group) if (parentDiscussionID != -1) { var parentDiscussionGroup = discussionList.GetItemById(parentDiscussionID); var destinationUrl = parentDiscussionGroup.Url + "/"
+ newDiscussionItem.Folder.Name;
newDiscussionItem.Folder.MoveTo(destinationUrl);
}
web.AllowUnsafeUpdates = false;
Using the above method of .Folder.MoveTo() any SPListItem can be moved to any destination. Hope this would help someone else.