Programmer's Guide:
Using Discussion Pages, Discussions, and Topics

In eRoom, a topic is an object that contains comments and/or polls. Any object that implements the IERUTopic interface is generically referred to as a Topic in this documentation. These include Topic Pages, which are pages that focus primarily on managing a topic, and also many other page types that have an embedded topic at the bottom of their pages.

A Discussion Page is essentially a constrained container page - the only kind of principal item it can contain is a Topic Page. Discussion Pages implement the IERUDiscussionPage interface.

Creating Discussion Pages and Topic Pages


To create a Discussion Page, use the CreateDiscussionPage method in IERUContainer. To create a Topic Page, use the CreateTopicPage method. Note that the CreateTopicPage method only works when called on a Discussion Page object. Similarly, IERUItem's MoveTo and CopyTo methods only allow Topic Pages to be moved or copied into Discussion Pages. To enable the embedded topic on another type of page, specify the erCreateOptIncludeComments flag in the create options passed to the Create function for that object type, or set its ShowTopic property to TRUE.

When you create a Discussion Page, you can specify one or more flags in the CreateOptions parameter that will dictate the page's layout and behavior. For instance, if you supply the flag erCreateOptAllowNestedResponses, the Topic Pages inside the Discussion Page will support multi-threaded topics; otherwise topics will be single-threaded. Or, you can specify erCreateOptShowDescription, which causes the page's description to be displayed. To specify none of the create options, use erCreateOptNone.

Dim NewDiscussionPage As IERUContainer
Dim NewTopicPage As IERUTopicPage
Set NewDiscussionPage = home.Container.CreateDiscussionPage( _
   "Holiday Party Brainstorming", erCreateOptAllowNestedResponses)
Set NewTopicPage = NewDiscussionPage.CreateTopicPage( _
   "Help plan the Holiday Party menu", erFormatPlainText, erCreateOptNone

Iterating through the contents of Topics


Topics can contain Comment and Poll objects. Comments can be single-threaded or multi-threaded, but Polls always appear at the outermost level. To simplify programming, SAAPI presents the contents of a Topic in a single list - this way you don't have to write recursive code to handle comment nesting. Instead, SAAPI returns the Comments and Polls in an ordered collection. Comment objects implement a property called Level, which indicates the nesting level that the comment occupies in a threaded discussion. The outermost level is level 0. If your code that processes the tree of Topic contents cares about the nesting level of the comments, you just need to pay attention to the Level property of the Comments as you iterate over them.

' Display the tree of Comments and Polls in a Topic
Dim Item as IERUItem
For Each Item in MyTopic.Items
If Item.Type = erItemTypeComment Then
  ' precede the name of the comment with one hyphen for each level of nesting
  Debug.Print String(Item.Comment.Level, "-") + Item.Name
Else
  Debug.Print Item.Name
End If
Next

Creating Comments and Polls in a Topic


A newly-created Comment can be in response to an existing Comment (if the Discussion Page allows multi-threaded topics), or it can be posted at the outermost level of the Topic. Either way, use the CreateComment method in IERUTopic. The pResponseTo parameter dictates whether the Comment created is independent of, or in response to, an existing Comment. To respond to an existing Comment, pass the existing Comment as the value for this parameter; to create an independent Comment, supply NULL (C++) or Nothing (scripting languages) as the value.

Dim NewComment as IERUItem
Set NewComment = MyTopic.CreateComment("My comment's title", _
"This is the body of my comment", erFormatPlainText, Nothing)


To create a Poll in a Topic, use the CreatePoll method:

Dim NewPoll as IERUItem
Dim Choices(2)
Choices(0) = "Boxers"
Choices(1) = "Briefs"
Set NewPoll = MyTopic.CreatePoll("Important Poll &endash; please vote!", _
"Boxers or Briefs?", erFormatPlainText, Choices, _
erCreateOptAllowWriteIn)