Warning: CAllPluginsApi will fail if your plugin and the other plugin are running in separate app domains. This will be the case with a default installation of FogBugz if your plugin wishes to query fields in Custom Fields, for example. See this article for an alternative (and easier) way to get and set another plugin's bug-joined fields.
Sometimes a FogBugz plugin needs to know about, or interact with, other plugins. In those cases, you can use CAllPluginsApi to detect and invoke other FogBugz plugins.
We'll use the FogBugz Reporting Plugin as our example.
Finding a specific plugin
The FogBugz Reporting plugin needs case history data in a different (and more query-performant) format than core FogBugz provides in order to generate over-time data. So it uses another plugin, CaseHistory, to create, backfill, and maintain this data. This is neat; now other plugins can access CaseHistory's data just like Reporting does.
On calls to PluginFromId, FogBugz will search all of the currently installed plugins for one with an ID that matches, and return it to the caller as a FogCreek.FogBugz.Plugins.Plugin object which can then be cast to make calls on the desired interface.
Creating a custom plugin interface
The Reporting plugin provides a framework for showing metric on FogBugz cases, and we wanted to provide an interface for other developers to create custom metrics. To do that, the reporting plugin needs to create its own custom interface, and look for other plugins that implement that interface.
With this in place, we can create a plugin-to-a-plugin! And that's exactly how the 'Reporting - Additional Metrics' plugin works. It implements IReportingMetrics, and acts as a plugin to the Reporting plugin.
Getting all fields from the CustomFields plugin (from another plugin)
Please see the warning at the top of this article. Another method for getting another plugin's fields is here.
It's now easy to get all of the Custom Fields defined by the user, even from a plugin other than CustomFields!
");\n }\n return "The Custom Fields plugin is installed, and its fields are:<br /><br />" + sb.ToString();\n}\n'}" plugin_content="" type="hidden">