Tutorials > Editing Cases
"Assign To Me" Plugin
This tutorial walks you through creation of a simple plugin which uses the API to commit changes to cases. You will learn the basics of adding some html to a case view, retrieving a FogBugz object (CBug), commiting the object to the database, and handling posts via the plugin raw page (see Implementing IPluginRawPageDisplay). Two possible enhancements to this plugin are suggested as well.
Note: This example makes use of a security action token to prevent cross-site request forgery. See Plugin Security to learn how to secure your plugin. It also uses the Notifications API to display errors.
This plugin solves a common problem which arises when multiple FogBugz users share a common queue of work. This can happen when more than one customer service representative is working in the Inbox project at the same time, or when several developers are pulling from a common pool of cases. Normally, with cases received via email, a user will signal to other users when she begins working on a case by clicking reply. FogBugz immediately assigns the case to them and other users can see the assignment and do not duplicate the work. In some cases, however, work on the case begins before the user starts composing the reply message. The user needs just needs to assign the case to herself.
This plugin adds a link to the top of the case view. When the user clicks it, she is sent to the plugin raw page which assigns the case or cases to her and then redirects back to the case(s).
This plugin adds a link to the top of case view, "Assign To Me" conveniently near the current assignment:
After clicking the link, the case view is reloaded, showing the assignment.
If multiple cases are being viewed, all are assigned to the currently logged in user. If a case is already assigned to her, it is not updated.
Compile and Install it on your own
Download the source file: AssignToMe.cs
Then follow these instructions to create a functioning plugin assembly: Compiling and Installing a FogBugz Plugin
Try adding a button in grid view to assign the selected cases to you. Implement IPluginFilterToolbar to create a CFilterTool. Use jquery to get the list of the currently selected cases and put them in the link URL.
This implementation uses the quick-and-dirty link and meta refresh to send the user to the plugin raw page and back to the case view. The plugin raw page is not usually shown directly to the user (as it lacks the standard FogBugz "chrome"). A more elegant way to commit the change would be via AJAX. See this simple example: Using IPluginRawPageDisplay to Handle AJAX Requests