Case Status Kiln
Register Log In


FogBugz Plugin Interfaces (All…»Implementing IPluginDiscussTop…
  • RSS Feed

Last modified on 12/15/2014 5:23 PM by User.


Implementing IPluginDiscussTopicJoin, IPluginDiscussTopicDisplay, and IPluginDiscussTopicCommit

FogBugz Plugin Interfaces > Discussion Groups > IPluginDiscussTopicJoin, IPluginDiscussTopicDisplay, and IPluginDiscussTopicCommit


This article will demonstrate a pair of simple FogBugz plugins that implement the IPluginDiscussTopicJoin, IPluginDiscussTopicDisplay, and IPluginDiscussTopicCommit interfaces contained in the FogCreek.FogBugz.Plugins.Interfaces class library.


IPluginDiscussTopicDisplay and IPluginDiscussTopicCommit

In this example, two plugins are created that each add a custom field to a FogBugz discussion groups topic. One adds a control allowing you assign a "Level of Awesomeness" to a discussion group topic, and the other adds text box input allowing you to give the topic a "Secret Code Name." In addition, each plugin generates a checkbox control allowing the user to force the IPluginDiscussGroupCommit function DiscussGroupCommitBefore to return false, thereby causing the commit to fail. To demonstrate how commit and rollback occurs (and the order in which they occur across two plugins that each implement IPluginDiscussGroupCommit), all of the member functions of IPluginPersonCommit generate a UI notification (using CPluginApi.Notifications) indicating that they were called.

If you upload the plugin and play around with it, you'll notice that:

  • For the DiscussTopicCommitBefore and DiscussTopicCommitAfter methods, FogBugz handles each plugin instance implementing IPluginDiscussTopicCommit in the order that the plugin was installed. (The CPluginApi.PluginPrefix property reveals this; for example it will return "P4" if called from the 4th plugin ever installed on the FogBugz site.)
  • For the DiscussTopicCommitRollback method, FogBugz first handles the plugin instance that returned false from DiscussTopicCommitBefore, then calls the DiscussTopicCommitRollback function of all plugin instances that previously called DiscussTopicCommitBefore in reverse order (ie, they're "popped off the stack.").


Each of the example plugins use the IPluginDiscussTopicJoin method to specify a table containing an integer "ixDiscussTopic" column, allowing FogBugz to automatically join the columns of that table to the "DiscussTopic" table. This allows the plugin developer to use CDiscussTopic.GetPluginField() and CDiscussTopic.GetPluginFieldOriginal() to easily retrieve column values from the joined table,  and use CDiscussTopic.SetPluginField() to specify a value to be set upon commit.




Compile and Install It On Your Own

Download the source files:   IPluginDiscussTopicJoin_Display_Commit_Example_1.cs, IPluginDiscussTopicJoin_Display_Commit_Example_2.cs

Then follow these instructions to create a functioning plugin assembly: Compiling and Installing a FogBugz Plugin