Programmatically Create Discussion Board Plus Threads and Replies Using PowerShell

A few days ago, I received an interesting request from a customer. He needed to create Bamboo Discussion Board Plus for SharePoint (DBP) threads and replies programmatically using a PowerShell script. I’m happy to more widely share via this post how to use Windows PowerShell (PS) to automatically create Discussion Board Plus threads and replies.

I’ve divided this post into three parts, and have included the PowerShell script files for your reference. You can download the PS files here first.

1. Create a new Discussion Board Plus (DBP) list for SharePoint:

When you create a new Discussion Board Plus list, please note the list template name in the create window. The name is “Discussion Board Plus.” This is the fixed name and should not be changed.

To create a new DBP list, we call the CreateNewDiscussionBoardPlus method in the CreateDBP.ps1, using the syntax as shown below:

CreateNewDiscussionBoardPlus -url http://server -listName "DBP" -listDescription "DescriptionofDiscussionBoard" -lisTemplate "Discussion Board Plus"
 
Where:
  • URL is your site URL.
  • listName is your DBP List Name.
  • listDescription is the description of the DBP.

To run the PS file, click on Start -> All Programs -> Accessories -> Windows PowerShell.

After that, you call the CreateDBP file (CreateDBP.ps1) as shown below:

In this example, I set the PS files in the DiscussionBoardPlus_PS_Scripts folder on the desktop. When you see message “your list is created in your site!” in the Windows PowerShell console, this means that your list has been created.

And now, you can check the list that was just created on the site:

2. Create the thread in Discussion Board Plus:

DBP has two content types, which include: BambooDiscussion and BambooMessage:

  • BambooDiscussion stands for the thread/topic.
  • BambooMessage stands for reply/message.

Some fields are required during the creation of a new thread/topic, such as: ContentType, Title, Body, ThreadIndex, and MessageId. If you want to insert more fields, you have to use their internal names. In this example, the value of ThreadIndex field is a hex string which is made from a complex number so I created a new type and used C# in PS.

To create a new thread, we call the CreateNewThreadDiscussion method in the Create_Thread_DBP.ps1 . It has syntax as shown below:

CreateNewThreadDiscussion -url http://server -listName "DBP" -subject "Subject of the Thread" -body "Body of the Thread"
 
 

Where:

  • URL is your site URL.
  • listName is your DBP List Name.
  • subject is the subject of the thread.
  • body is the body of the thread.

Next, open your PS console and run Create_Thread_DBP file (Create_Thread_DBP.ps1):

When you see the message, “A new Thread is created successfully in Discussion Board Plus…” in the PowerShell console, this means that the new thread has been created.

After the PS script has run successfully, return to the DBP list and hit F5 to see the result:

3. Create the reply for the existing thread:

In DBP, thread/topic item is a folder item. To create a new reply on the topic, you must know the title of the topic. We use the title to find out the folder and then insert the reply item into a thread. ContentType, ParentFolderId, Body, ThreadIndex, MessageId are all required fields. If you want to insert more fields, you’ll need to use their internal names. ParentFolderId field is Id of the topic, and ThreadIndex field inherits from the topic’s ThreadIndex.

To create a new reply, we call the CreateNewReplyThreadDiscussion method in Create_Reply_Thread_DBP.ps1. It has syntax as shown below:

CreateNewReplyThreadDiscussion -url "http://phong2008:81" -listName "DBP" -threadTitle "Subject of the Thread" -body "Body of the Thread"
 
 

Where: 

  • URL is your site URL.
  • listName is your DBP List Name.
  • threadTitle is the Title of the thread to which you want to add the reply.
  • body is the body of the reply.

Open the PS console and run the Create_Reply_Thread_DBP file (Create_Reply_Thread_DBP.ps1):

When you see the message, “A new reply is created successfully…” in the PowerShell console, this means that the new reply has been created.

After the PS script has run successfully, return to the DBP list and hit F5 to see the result:

Have a nice day!


SharePoint

Applications

SharePoint apps are stand-alone applications that perform specific tasks on a SharePoint site. Apps can perform functions such as managing a discussion board or knowledge base, performing project management or time tracking tasks, or doing other workflow operations.

SharePoint

Product Suites

Experience greater power and savings by bundling our SharePoint apps and web parts.


Essentials


Essentials Plus


Bamboo Premier


Project Management Suite


Knowledge Management Suite


External User Manager


SharePoint

Web Parts

Extend SharePoint beyond its out-of-the-box capabilities by tailoring it to your requirements with Bamboo Solution’s growing portfolio of Web Parts. Web Parts are the building blocks of pages on a SharePoint site that can be used to customize the user interface and content of a site page. 

SharePoint

Product Suites

Experience greater power and savings by bundling our SharePoint apps and web parts.


Essentials


Essentials Plus


Bamboo Premier


Project Management Suite


Knowledge Management Suite


External User Manager


Office 365

Cloud Parts

Cloud Parts are functional components that extend your SharePoint environment whether it’s hosted, on-premises, or part of Microsoft Office 365. More than mere ports of existing software to the cloud, our Cloud Parts have been built from the ground up to take advantage of the best that the cloud has to offer.

SharePoint

Product Suites

Experience greater power and savings by bundling our SharePoint apps and web parts.


Cloud Parts Suite for O365/SP Onl.


Featured Services

SharePoint Health Check

A SharePoint Health Check will identify the causes of issues and risks associated with your specific environment, and is custom tailored to provide you with the best recommendations to optimize your SharePoint environment.

SQL Health Check

Document recommendations relating to performance, stability, availability, or a specific focus you request of your SQL Server database instances.

My SharePointXperts

The truth is that each SharePoint skill may not be a full time job for many organizations, and it is nearly impossible for one person to do everything you need – so augment your team with SharePointXperts; providing the skill sets you need when you need them!